• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSURL URLWithString:relativeToURL: generates an extra /
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: External Drives Questions
  • Next by Date: Re: External Drives Questions
  • Previous by thread: Re: Question about font managing (NSFont).
  • Next by thread: Finding objects in a NSDocument
  • Index(es):
    • Date
    • Thread