NSURL URLWithString:relativeToURL: generates an extra /
NSURL URLWithString:relativeToURL: generates an extra /
- Subject: NSURL URLWithString:relativeToURL: generates an extra /
- From: Fritz Anderson <email@hidden>
- Date: Mon, 29 Jun 2009 13:05:04 -0500
I've worked around this by simply building my URL string completely by
hand, but I'd like to learn...
iPhone OS 3.0.
At +initialize time, my class sets up a static NSURL object:
sBaseURL = [[NSURL alloc] initWithScheme: @"http"
host: @"www.example.com:8080"
path: @"/"];
NSURL treats an empty or nil path as illegal.
Later, I build up a path:
NSMutableString * path = [NSMutableString stringWithString: @"calendar/
join?"];
[path appendFormat: @"start_date=%@", [sDirserverParamFormat
stringFromDate: start]];
[path appendFormat: @"&end_date=%@", [sDirserverParamFormat
stringFromDate: finish]];
(sDirserverParamFormat is an NSDateFormatter static.)
And then I construct the URL I want to load from:
NSURL * queryURL = [NSURL URLWithString: path relativeToURL:
sBaseURL];
However, the resulting URL chokes my server (Rails 2.x, if it
matters). The URL string generated by this method is like
http://www.example.com:8080//calendar/join?start_date=20090601&end_date=20090630
Note the doubled slash before "calendar." My server is perfectly happy
if it's a single slash.
Is this a nonconformity in my server, or should I be able to use
relative paths in NSURL to generate paths without double slashes? If
the latter, how do I do that?
I've Googled "NSURL double slash," and found an "openradar" bug that's
similar. If nobody has guidance on this, I'll file a real radar.
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden