From e40a76715a11b1465c10076f975ff7335c84cf30 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 18 Mar 2019 22:59:56 -0700 Subject: [PATCH] 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 --- Libraries/Image/RCTImageLoader.m | 5 ----- React/Base/RCTUtils.m | 3 --- 2 files changed, 8 deletions(-) diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index 13a485f412..527db52971 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -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]; } diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 44e9516bf9..7a039ef89f 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -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]; }