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 коммит произвёл Facebook Github Bot
Родитель c2f5b676ff
Коммит e40a76715a
2 изменённых файлов: 0 добавлений и 8 удалений

Просмотреть файл

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

Просмотреть файл

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