File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Parse/Internal/HTTPRequest Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ + (NSURL *)URLFromAbsoluteString:(NSString *)string
2424 if (path.length != 0 ) {
2525 NSString *fullPath = (components.path .length ? components.path : @" /" );
2626 fullPath = [fullPath stringByAppendingPathComponent: path];
27+ // If the last character in the provided path is a `/` -> `stringByAppendingPathComponent:` will remove it.
28+ // so we need to append it manually to make sure we contruct with the requested behavior.
29+ if ([path characterAtIndex: path.length - 1 ] == ' /' &&
30+ [fullPath characterAtIndex: fullPath.length - 1 ] != ' /' ) {
31+ fullPath = [fullPath stringByAppendingString: @" /" ];
32+ }
2733 components.path = fullPath;
2834 }
2935 if (query) {
Original file line number Diff line number Diff line change @@ -61,6 +61,18 @@ - (void)testURLWithPath {
6161 path: @" /100500/yolo"
6262 query: nil ].absoluteString ,
6363 @" https://yolo.com/abc/xyz/100500/yolo" );
64+ XCTAssertEqualObjects ([PFURLConstructor URLFromAbsoluteString: @" https://yolo.com/"
65+ path: @" /yolo/"
66+ query: nil ].absoluteString ,
67+ @" https://yolo.com/yolo/" );
68+ XCTAssertEqualObjects ([PFURLConstructor URLFromAbsoluteString: @" https://yolo.com/"
69+ path: @" a/yolo/"
70+ query: nil ].absoluteString ,
71+ @" https://yolo.com/a/yolo/" );
72+ XCTAssertEqualObjects ([PFURLConstructor URLFromAbsoluteString: @" https://yolo.com/"
73+ path: @" /a/yolo/"
74+ query: nil ].absoluteString ,
75+ @" https://yolo.com/a/yolo/" );
6476}
6577
6678@end
You can’t perform that action at this time.
0 commit comments