Fixed CFURLCopyPath() returning NULL for "//" path

Fix #297
This commit is contained in:
Pierre-Olivier Latour
2017-08-21 08:37:49 +02:00
parent 44ffec1cf6
commit b4927bdd75

View File

@@ -300,6 +300,9 @@ NS_ASSUME_NONNULL_END
GWS_DCHECK(requestURL);
}
NSString* urlPath = requestURL ? CFBridgingRelease(CFURLCopyPath((CFURLRef)requestURL)) : nil; // Don't use -[NSURL path] which strips the ending slash
if (urlPath == nil) {
urlPath = @"/"; // CFURLCopyPath() returns NULL for a relative URL with path "//" contrary to -[NSURL path] which returns "/"
}
NSString* requestPath = urlPath ? GCDWebServerUnescapeURLString(urlPath) : nil;
NSString* queryString = requestURL ? CFBridgingRelease(CFURLCopyQueryString((CFURLRef)requestURL, NULL)) : nil; // Don't use -[NSURL query] to make sure query is not unescaped;
NSDictionary* requestQuery = queryString ? GCDWebServerParseURLEncodedForm(queryString) : @{};