Skip to content

Commit

Permalink
[iOS] Add png extension only if file exist when load local image
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Oct 11, 2024
1 parent 0d6908f commit 2f0c1ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/react-native/Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req

// Add missing png extension
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
NSURL *pngRequestURL = [request.URL URLByAppendingPathExtension:@"png"];
if ([[NSFileManager defaultManager] fileExistsAtPath:pngRequestURL.path]) {
mutableRequest.URL = pngRequestURL;
}
}
if (_redirectDelegate != nil) {
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
Expand Down

0 comments on commit 2f0c1ec

Please sign in to comment.