Remove explicitly add png file extension when load local image (#23864)

Summary:
We need to remove adding png file extension when path has not extension. Two reasons:
1. `imageWithContentsOfFile` or other `UIKit` methods can load png image correctly, even if path has not `png` file extension.
2. Sometimes, people may have file that actually not have file extension, it's the designated behavior for user. Like #23844 .

CC. sahrens cpojer .

[iOS] [Fixed] - Remove explicitly add png file extension when load local image
Pull Request resolved: https://github.com/facebook/react-native/pull/23864

Reviewed By: shergin

Differential Revision: D14425373

Pulled By: hramos

fbshipit-source-id: 3cc06c9a3d68cadf652c1de742f3cce26258c874
This commit is contained in:
zhongwuzw
2019-03-18 22:59:56 -07:00
committed by Facebook Github Bot
parent c2f5b676ff
commit e40a76715a
2 changed files with 0 additions and 8 deletions

View File

@@ -380,11 +380,6 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
[NSURLProtocol setProperty:@"RCTImageLoader"
forKey:@"trackingName"
inRequest:mutableRequest];
// Add missing png extension
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
}
if (_redirectDelegate != nil) {
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
}

View File

@@ -711,9 +711,6 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
if (!image) {
// Attempt to load from the file system
NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]];
if (filePath.pathExtension.length == 0) {
filePath = [filePath stringByAppendingPathExtension:@"png"];
}
image = [UIImage imageWithContentsOfFile:filePath];
}