NSURL creation problem with colon: a partial workaround
NSURL creation problem with colon: a partial workaround
- Subject: NSURL creation problem with colon: a partial workaround
- From: Jérome Laurens <email@hidden>
- Date: Thu, 18 Dec 2008 15:05:40 +0100
Hi list,
I have a relative path with colons "file:test", and I would like to
create a NSURL relative to a given base URL "file://localhost/root/".
This does not work as expected.
Consider the simple URL creation method
NSURL * url1 = [NSURL fileURLWithPath:@"/root/file:test"];
The url is properly created and its absoluteURL reads
file://localhost/root/file:test/
If I use a base URL things go wrong
NSURL * url2 = [NSURL fileURLWithPath:@"/root/"];
NSURL * url3 = [NSURL URLWithString:@"file:test" relativeToURL:url2];
The absolute URL of url3 reads
file:test
which is not the expected value.
Apparently NSURL parses the string as if there were no base URL at all,
which produces a wrong value.
Fortunately, there is a warkaround by prepending "./" to the relative
path.
NSURL * url4 = [NSURL URLWithString:@"./file:test" relativeToURL:url2];
The absolute URL of url4 reads
file://localhost/root/file:test
what is the expected value.
But the standardizedURL still reads the wrong value
file:test
So prepending "./" to the relative path is just a partial workaround.
Regards
_______________________________________________
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