Re: NSURL relativePath problem
Re: NSURL relativePath problem
- Subject: Re: NSURL relativePath problem
- From: Alex Zavatone <email@hidden>
- Date: Thu, 29 Aug 2013 14:13:31 -0400
Are you sure it's not the trailing forward slash on your root?
FYI, the way that certain characters are encoded after a ? is different than how you would normally do it. Just in case you need to escape spaces within parameters, use a + after the ?.
In any case, what we ended up doing was to build the NSString and make sure it was properly formatted first. This way, we could easily copy and paste it into a browser session and verify that the string will make a valid URL.
Once we had that, we simply did an NSURL URLWithString and we would always know it would be a good URL and one that is easily testable if something goes wrong.
I think we made sure the root was properly encoded first, then ran the query string through an encode method that was fit for parameters after the ?, appended those results into one string and did the URLWithString.
Hope this helps.
Cheers.
- Alex
On Aug 29, 2013, at 2:02 PM, Koen van der Drift wrote:
> I'm having some difficulties constructing a URL from a baseURL and a relativeURL when the relativeURL starts with a question mark:
>
> NSURL *baseURL = [NSURL URLWithString: @"http://www.test.com/test/"];
> NSString *relativeString = @"?query=test";
>
> NSURL *url = [NSURL URLWithString: relativeString relativeToURL: baseURL];
>
> This results in the following url:
>
> ?query=test -- http://www.test.com/test/
>
> While I want it to be:
>
> http://www.test.com/test/?query=test
>
>
> I can just generate the whole URL at once, but I was wondering why I get this behavior?
>
>
> Thanks,
>
> - Koen.
>
>
>
>
>
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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