Why in NSURL trailing slashes initialized by initWithScheme ...?
When using an initializer NSURL
initWithScheme:(NSString *) host:(NSString *) path:(NSString *)
iOS for some reason adds two extra trailing slashes if the path ends with a slash, if only @"/"
.
Does anyone know why this is the case, and if he has a way other than composing the url manually with something like
[NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@", scheme, host, path]];
UPDATE: A bug report has been sent to Apple.
+3
source to share
2 answers
File paths start with a "/" character but do not end with a "/" character.
From: Unified Resource Locator :
Syntax:
scheme://[user:password@]domain:port/path?query_string#fragment_id
Directory paths have a trailing "/", but they - initWithScheme:host:path:
don't seem to support them and might just be an Apache convention.
+1
source to share