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 (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

Reply via email to