Re: Weird behavior of -URLByAppendingPathComponent:

2011-06-20 Thread Nathan Sims
FWIW, the standard (can't remember which RFC I saw this in) is for treating a 
double slash // (or any number of slashes) as a single slash / in URLs (after 
the initial http://).


On Jun 19, 2011, at 9:14 PM, Jens Alfke wrote:

 Something seems wrong with -[NSURL URLByAppendingPathComponent:] --
 
 (gdb) po baseURL
 http://127.0.0.1:5984/
 (gdb) po [baseURL URLByAppendingPathComponent: @foo]
 http://127.0.0.1:5984/foo
 (gdb) po [baseURL URLByAppendingPathComponent: @foo/]
 http://127.0.0.1:5984/foo//
 
 Why the doubled slash at the end, in the third result? There should only be 
 one. I’m not sure if doubled slashes are actually illegal in URL paths, but 
 they’re certainly weird, and I’m pretty sure they’d confuse a lot of 
 websites. I’m guessing this is a CF bug.
 
 [This is on OS X 10.6.7.]
 
 And yes, I know about +URLWithString:relativeToURL: … but that method doesn’t 
 do the same thing. It only appends the string if the original URL ends with a 
 “/“, otherwise it replaces the last path component. (Which is correct 
 behavior for interpreting relative paths, just not what I want.)
 
 —Jens___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/newslists%40autonomy.caltech.edu
 
 This email sent to newsli...@autonomy.caltech.edu

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Weird behavior of -URLByAppendingPathComponent:

2011-06-19 Thread Jens Alfke
Something seems wrong with -[NSURL URLByAppendingPathComponent:] --

(gdb) po baseURL
http://127.0.0.1:5984/
(gdb) po [baseURL URLByAppendingPathComponent: @foo]
http://127.0.0.1:5984/foo
(gdb) po [baseURL URLByAppendingPathComponent: @foo/]
http://127.0.0.1:5984/foo//

Why the doubled slash at the end, in the third result? There should only be 
one. I’m not sure if doubled slashes are actually illegal in URL paths, but 
they’re certainly weird, and I’m pretty sure they’d confuse a lot of websites. 
I’m guessing this is a CF bug.

[This is on OS X 10.6.7.]

And yes, I know about +URLWithString:relativeToURL: … but that method doesn’t 
do the same thing. It only appends the string if the original URL ends with a 
“/“, otherwise it replaces the last path component. (Which is correct behavior 
for interpreting relative paths, just not what I want.)

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Weird behavior of -URLByAppendingPathComponent:

2011-06-19 Thread Tony Romano
I can repro that as well, and I'd say it's a bug.  I also tried this as
well:


Using:  NSURL *baseURL = [NSURL URLWithString:@http://129.0.0.1/;];

(gdb) po [baseURL URLByAppendingPathComponent: @/foo]
http://129.0.0.1//foo



according to the discussion for URLAppendingPathComponent:

If the original URL does not end with a forward slash and pathComponent
does not begin with a forward slash, a forward slash is inserted between
the two parts of the returned URL, unless the original URL is the empty
string.

It puts the slash in.


Tony Romano



On 6/19/11 9:14 PM, Jens Alfke j...@mooseyard.com wrote:

Something seems wrong with -[NSURL URLByAppendingPathComponent:] --

(gdb) po baseURL
http://127.0.0.1:5984/
(gdb) po [baseURL URLByAppendingPathComponent: @foo]
http://127.0.0.1:5984/foo
(gdb) po [baseURL URLByAppendingPathComponent: @foo/]
http://127.0.0.1:5984/foo//

Why the doubled slash at the end, in the third result? There should only
be one. I¹m not sure if doubled slashes are actually illegal in URL
paths, but they¹re certainly weird, and I¹m pretty sure they¹d confuse a
lot of websites. I¹m guessing this is a CF bug.

[This is on OS X 10.6.7.]

And yes, I know about +URLWithString:relativeToURL: Š but that method
doesn¹t do the same thing. It only appends the string if the original URL
ends with a ³/³, otherwise it replaces the last path component. (Which is
correct behavior for interpreting relative paths, just not what I want.)

‹Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tonyrom%40hotmail.com

This email sent to tony...@hotmail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com