mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-18 12:22:20 +08:00
Clean up some URL path handling
Reviewed By: sahrens Differential Revision: D5753338 fbshipit-source-id: 0eb1b4ae64ad7170f1b97f398ff11b713c695b12
This commit is contained in:
committed by
Facebook Github Bot
parent
3834cb5f68
commit
998197f444
@@ -314,7 +314,7 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
|
||||
|
||||
// Add missing png extension
|
||||
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
|
||||
mutableRequest.URL = [NSURL fileURLWithPath:[request.URL.path stringByAppendingPathExtension:@"png"]];
|
||||
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
|
||||
}
|
||||
request = mutableRequest;
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ NSString *__nullable RCTBundlePathForURL(NSURL *__nullable URL)
|
||||
// Not a file path
|
||||
return nil;
|
||||
}
|
||||
NSString *path = URL.path;
|
||||
NSString *path = [NSString stringWithUTF8String:[URL fileSystemRepresentation]];
|
||||
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
|
||||
if (![path hasPrefix:bundlePath]) {
|
||||
// Not a bundle-relative file
|
||||
@@ -678,11 +678,13 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
||||
|
||||
if (!image) {
|
||||
// Attempt to load from the file system
|
||||
NSString *filePath = imageURL.path;
|
||||
if (filePath.pathExtension.length == 0) {
|
||||
filePath = [filePath stringByAppendingPathExtension:@"png"];
|
||||
NSData *fileData;
|
||||
if (imageURL.pathExtension.length == 0) {
|
||||
fileData = [NSData dataWithContentsOfURL:[imageURL URLByAppendingPathExtension:@"png"]];
|
||||
} else {
|
||||
fileData = [NSData dataWithContentsOfURL:imageURL];
|
||||
}
|
||||
image = [UIImage imageWithContentsOfFile:filePath];
|
||||
image = [UIImage imageWithData:fileData];
|
||||
}
|
||||
|
||||
if (!image && !bundle) {
|
||||
|
||||
Reference in New Issue
Block a user