NSURL category to return the full path, with trailing slash and query parameters
@implementation NSURL (PathHelper)
-(NSString*)fullPathWithQuery;
{
// getting a path without the trailing slash stripped is annoying.
NSString *pathWithPrevervedTrailingSlash = [CFBridgingRelease(CFURLCopyPath((CFURLRef)self)) stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if (self.query) {
return [NSString stringWithFormat:@"%@?%@", pathWithPrevervedTrailingSlash, self.query];
} else {
return pathWithPrevervedTrailingSlash;
}
}
@end
Might even work…