From e4a545a485fc9a8fd4a8977f5b926eb1781fb502 Mon Sep 17 00:00:00 2001 From: Abraham Przewodnik Date: Mon, 14 Sep 2020 12:02:16 +0200 Subject: [PATCH] Remove IOS7 polyfill for containsString --- ios/IOS7Polyfill.h | 27 ----------------------- ios/RNFetchBlob.xcodeproj/project.pbxproj | 2 -- ios/RNFetchBlobFS.m | 3 +-- ios/RNFetchBlobReqBuilder.m | 7 +++--- ios/RNFetchBlobRequest.m | 11 +++++---- 5 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 ios/IOS7Polyfill.h diff --git a/ios/IOS7Polyfill.h b/ios/IOS7Polyfill.h deleted file mode 100644 index 04a4bfaaf..000000000 --- a/ios/IOS7Polyfill.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// IOS7Polyfill.h -// RNFetchBlob -// -// Created by Ben Hsieh on 2016/9/6. -// Copyright © 2016年 wkh237.github.io. All rights reserved. -// - -#ifndef IOS7Polyfill_h -#define IOS7Polyfill_h - -@interface NSString (Contains) - -- (BOOL)RNFBContainsString:(NSString*)other; - -@end - -@implementation NSString (Contains) - -- (BOOL)RNFBContainsString:(NSString*)other { - NSRange range = [self rangeOfString:other]; - return range.length != 0; -} - - -@end -#endif /* IOS7Polyfill_h */ diff --git a/ios/RNFetchBlob.xcodeproj/project.pbxproj b/ios/RNFetchBlob.xcodeproj/project.pbxproj index 4fbdc00ea..e08dc8e1e 100644 --- a/ios/RNFetchBlob.xcodeproj/project.pbxproj +++ b/ios/RNFetchBlob.xcodeproj/project.pbxproj @@ -45,7 +45,6 @@ A19B48241D98102400E6868A /* RNFetchBlobProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFetchBlobProgress.m; sourceTree = ""; }; A1AAE2971D300E3E0051D11C /* RNFetchBlobReqBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFetchBlobReqBuilder.h; sourceTree = ""; }; A1AAE2981D300E4D0051D11C /* RNFetchBlobReqBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFetchBlobReqBuilder.m; sourceTree = ""; }; - A1F950181D7E9134002A95A6 /* IOS7Polyfill.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOS7Polyfill.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -71,7 +70,6 @@ children = ( A19B48241D98102400E6868A /* RNFetchBlobProgress.m */, A19B48231D98100800E6868A /* RNFetchBlobProgress.h */, - A1F950181D7E9134002A95A6 /* IOS7Polyfill.h */, A1AAE2981D300E4D0051D11C /* RNFetchBlobReqBuilder.m */, A1AAE2971D300E3E0051D11C /* RNFetchBlobReqBuilder.h */, A158F42E1D0539CE006FFD38 /* RNFetchBlobNetwork.h */, diff --git a/ios/RNFetchBlobFS.m b/ios/RNFetchBlobFS.m index e597ee5d5..c013d80e4 100644 --- a/ios/RNFetchBlobFS.m +++ b/ios/RNFetchBlobFS.m @@ -10,7 +10,6 @@ #import "RNFetchBlob.h" #import "RNFetchBlobFS.h" #import "RNFetchBlobConst.h" -#import "IOS7Polyfill.h" @import AssetsLibrary; #import @@ -375,7 +374,7 @@ + (void) writeFile:(NSString *)path NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:path]; NSData * content = nil; - if([encoding RNFBContainsString:@"base64"]) { + if([encoding containsString:@"base64"]) { content = [[NSData alloc] initWithBase64EncodedString:data options:0]; } else if([encoding isEqualToString:@"uri"]) { diff --git a/ios/RNFetchBlobReqBuilder.m b/ios/RNFetchBlobReqBuilder.m index 16963bb5f..68ee34f71 100644 --- a/ios/RNFetchBlobReqBuilder.m +++ b/ios/RNFetchBlobReqBuilder.m @@ -11,7 +11,6 @@ #import "RNFetchBlobNetwork.h" #import "RNFetchBlobConst.h" #import "RNFetchBlobFS.h" -#import "IOS7Polyfill.h" #if __has_include() #import @@ -117,7 +116,7 @@ +(void) buildOctetRequest:(NSDictionary *)options orgPath = [RNFetchBlobFS getPathOfAsset:orgPath]; if([orgPath hasPrefix:AL_PREFIX]) { - + [RNFetchBlobFS readFile:orgPath encoding:nil onComplete:^(id content, NSString* code, NSString * err) { if(err != nil) { @@ -131,7 +130,7 @@ +(void) buildOctetRequest:(NSDictionary *)options onComplete(request, [((NSData *)content) length]); } }]; - + return; } size = [[[NSFileManager defaultManager] attributesOfItemAtPath:orgPath error:nil] fileSize]; @@ -150,7 +149,7 @@ +(void) buildOctetRequest:(NSDictionary *)options __block NSString * cType = [[self class]getHeaderIgnoreCases:@"content-type" fromHeaders:mheaders]; // when content-type is application/octet* decode body string using BASE64 decoder - if([[cType lowercaseString] hasPrefix:@"application/octet"] || [[cType lowercaseString] RNFBContainsString:@";base64"]) + if([[cType lowercaseString] hasPrefix:@"application/octet"] || [[cType lowercaseString] containsString:@";base64"]) { __block NSString * ncType = [[cType stringByReplacingOccurrencesOfString:@";base64" withString:@""]stringByReplacingOccurrencesOfString:@";BASE64" withString:@""]; if([mheaders valueForKey:@"content-type"] != nil) diff --git a/ios/RNFetchBlobRequest.m b/ios/RNFetchBlobRequest.m index cdbe6b1e5..8db644453 100644 --- a/ios/RNFetchBlobRequest.m +++ b/ios/RNFetchBlobRequest.m @@ -12,7 +12,6 @@ #import "RNFetchBlobConst.h" #import "RNFetchBlobReqBuilder.h" -#import "IOS7Polyfill.h" #import @@ -214,20 +213,20 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat return; } else { - self.isServerPush = [[respCType lowercaseString] RNFBContainsString:@"multipart/x-mixed-replace;"]; + self.isServerPush = [[respCType lowercaseString] containsString:@"multipart/x-mixed-replace;"]; } if(respCType) { NSArray * extraBlobCTypes = [options objectForKey:CONFIG_EXTRA_BLOB_CTYPE]; - if ([respCType RNFBContainsString:@"text/"]) { + if ([respCType containsString:@"text/"]) { respType = @"text"; - } else if ([respCType RNFBContainsString:@"application/json"]) { + } else if ([respCType containsString:@"application/json"]) { respType = @"json"; } else if(extraBlobCTypes) { // If extra blob content type is not empty, check if response type matches for (NSString * substr in extraBlobCTypes) { - if ([respCType RNFBContainsString:[substr lowercaseString]]) { + if ([respCType containsString:[substr lowercaseString]]) { respType = @"blob"; respFile = YES; destPath = [RNFetchBlobFS getTempPath:taskId withExtension:nil]; @@ -285,7 +284,7 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat // if not set overwrite in options, defaults to TRUE BOOL overwrite = [options valueForKey:@"overwrite"] == nil ? YES : [[options valueForKey:@"overwrite"] boolValue]; - BOOL appendToExistingFile = [destPath RNFBContainsString:@"?append=true"]; + BOOL appendToExistingFile = [destPath containsString:@"?append=true"]; appendToExistingFile = !overwrite;