Skip to content

Commit ef4ea27

Browse files
committed
Fix the rare case that a path contains the percent sign, will cause create URL failed
1 parent 34203ff commit ef4ea27

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Storage/FirebaseStorageUI/NSURL+SDWebImageFIRStorageLoader.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ + (instancetype)sd_URLWithStorageReference:(FIRStorageReference *)storageRef {
3333
return nil;
3434
}
3535
// gs://bucket/path/to/object.txt
36-
NSString *urlString = [NSString stringWithFormat:@"%@://%@/%@", SDWebImageFIRStorageScheme, storageRef.bucket, storageRef.fullPath];
37-
NSURL *url = [NSURL URLWithString:urlString];
36+
NSURLComponents *components = [[NSURLComponents alloc] initWithString:[NSString stringWithFormat:@"%@://%@/", SDWebImageFIRStorageScheme, storageRef.bucket]];
37+
NSString *encodedPath = [storageRef.fullPath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];
38+
components.path = [components.path stringByAppendingString:encodedPath];
39+
40+
NSURL *url = components.URL;
3841
if (!url) {
3942
return nil;
4043
}

0 commit comments

Comments
 (0)