fix(lib): move to local variable instead of relying on the string constant from RN core (#63)

This commit is contained in:
Bartol Karuza 2019-06-18 17:32:38 +02:00 committed by GitHub
parent f321084c7b
commit a2d39f0971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,8 @@
@implementation RNCAssetsLibraryRequestHandler @implementation RNCAssetsLibraryRequestHandler
NSString *const PHUploadScheme = @"ph-upload";
RCT_EXPORT_MODULE() RCT_EXPORT_MODULE()
#pragma mark - RNCURLRequestHandler #pragma mark - RNCURLRequestHandler
@ -32,7 +34,7 @@ RCT_EXPORT_MODULE()
return [request.URL.scheme caseInsensitiveCompare:@"assets-library"] == NSOrderedSame return [request.URL.scheme caseInsensitiveCompare:@"assets-library"] == NSOrderedSame
|| [request.URL.scheme caseInsensitiveCompare:@"ph"] == NSOrderedSame || [request.URL.scheme caseInsensitiveCompare:@"ph"] == NSOrderedSame
|| [request.URL.scheme caseInsensitiveCompare:RCTNetworkingPHUploadHackScheme] == NSOrderedSame; || [request.URL.scheme caseInsensitiveCompare:PHUploadScheme] == NSOrderedSame;
} }
- (id)sendRequest:(NSURLRequest *)request - (id)sendRequest:(NSURLRequest *)request
@ -44,9 +46,9 @@ RCT_EXPORT_MODULE()
}; };
NSURL *requestURL = request.URL; NSURL *requestURL = request.URL;
BOOL isPHUpload = [requestURL.scheme caseInsensitiveCompare:RCTNetworkingPHUploadHackScheme] == NSOrderedSame; BOOL isPHUpload = [requestURL.scheme caseInsensitiveCompare:PHUploadScheme] == NSOrderedSame;
if (isPHUpload) { if (isPHUpload) {
requestURL = [NSURL URLWithString:[@"ph" stringByAppendingString:[requestURL.absoluteString substringFromIndex:RCTNetworkingPHUploadHackScheme.length]]]; requestURL = [NSURL URLWithString:[@"ph" stringByAppendingString:[requestURL.absoluteString substringFromIndex:PHUploadScheme.length]]];
} }
if (!requestURL) { if (!requestURL) {