Permalink
Browse files

Remove the user from the url and do some manual encoding

  • Loading branch information...
kgn committed Mar 13, 2012
1 parent 73bc228 commit 2b88973679e6bbab1ebdda6c33a88a40beafb3bd
Showing with 9 additions and 3 deletions.
  1. +1 −1 Shared/NSString+KGFile.h
  2. +8 −2 Shared/NSString+KGFile.m
View
@@ -13,6 +13,6 @@
- (NSString *)validFilename;
- (NSString *)validFilenameAllowHidden:(BOOL)allowHidden;
-- (NSURL *)volumeMountURLWithError:(NSError **)error;
+- (NSString *)volumeMountURLWithError:(NSError **)error;
@end
View
@@ -41,7 +41,7 @@ - (NSString *)validFilenameAllowHidden:(BOOL)allowHidden{
return [newString substringFromIndex:i];
}
-- (NSURL *)volumeMountURLWithError:(NSError **)error{
+- (NSString *)volumeMountURLWithError:(NSError **)error{
NSURL *testURL = [NSURL fileURLWithPath:self];
NSMutableArray *pathComponents = [NSMutableArray array];
while(testURL != nil){
@@ -87,7 +87,13 @@ - (NSURL *)volumeMountURLWithError:(NSError **)error{
}
#endif
- return [volURL URLByAppendingPathComponent:[NSString pathWithComponents:pathComponents]];
+ // remove the username from the path if it's there
+ NSURL *fullURL= [volURL URLByAppendingPathComponent:[NSString pathWithComponents:pathComponents]];
+ NSURL *trimedUrl = [[[NSURL alloc] initWithScheme:[fullURL scheme] host:[fullURL host] path:[fullURL path]] autorelease];
+ // ; or ? doesn't get escaped so do it manually
+ return [[[trimedUrl absoluteString]
+ stringByReplacingOccurrencesOfString:@";" withString:@"%3B"]
+ stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"];
}
@end

0 comments on commit 2b88973

Please sign in to comment.