From c6fc576372591afab41f1ed5d012fb88a1e70f80 Mon Sep 17 00:00:00 2001 From: Neil Cowburn Date: Thu, 14 Apr 2022 16:35:01 +0100 Subject: [PATCH] Remove redundant iOS 7 polyfill --- ios/IOS7Polyfill.h | 27 ------------------- .../project.pbxproj | 2 -- ios/ReactNativeBlobUtilFS.m | 3 +-- ios/ReactNativeBlobUtilReqBuilder.m | 3 +-- ios/ReactNativeBlobUtilRequest.m | 11 ++++---- 5 files changed, 7 insertions(+), 39 deletions(-) delete mode 100644 ios/IOS7Polyfill.h diff --git a/ios/IOS7Polyfill.h b/ios/IOS7Polyfill.h deleted file mode 100644 index d457c17b3..000000000 --- a/ios/IOS7Polyfill.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// IOS7Polyfill.h -// ReactNativeBlobUtil -// -// 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/ReactNativeBlobUtil.xcodeproj/project.pbxproj b/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj index 0a7ed618b..9793ffe24 100644 --- a/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj +++ b/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj @@ -48,7 +48,6 @@ A19B48241D98102400E6868A /* ReactNativeBlobUtilProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactNativeBlobUtilProgress.m; sourceTree = ""; }; A1AAE2971D300E3E0051D11C /* ReactNativeBlobUtilReqBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReactNativeBlobUtilReqBuilder.h; sourceTree = ""; }; A1AAE2981D300E4D0051D11C /* ReactNativeBlobUtilReqBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactNativeBlobUtilReqBuilder.m; sourceTree = ""; }; - A1F950181D7E9134002A95A6 /* IOS7Polyfill.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOS7Polyfill.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -76,7 +75,6 @@ 9FD8D3C126F1709A00009F35 /* ReactNativeBlobUtilFileTransformer.h */, A19B48241D98102400E6868A /* ReactNativeBlobUtilProgress.m */, A19B48231D98100800E6868A /* ReactNativeBlobUtilProgress.h */, - A1F950181D7E9134002A95A6 /* IOS7Polyfill.h */, A1AAE2981D300E4D0051D11C /* ReactNativeBlobUtilReqBuilder.m */, A1AAE2971D300E3E0051D11C /* ReactNativeBlobUtilReqBuilder.h */, A158F42E1D0539CE006FFD38 /* ReactNativeBlobUtilNetwork.h */, diff --git a/ios/ReactNativeBlobUtilFS.m b/ios/ReactNativeBlobUtilFS.m index 36afe62f6..b66c48a47 100644 --- a/ios/ReactNativeBlobUtilFS.m +++ b/ios/ReactNativeBlobUtilFS.m @@ -11,7 +11,6 @@ #import "ReactNativeBlobUtilFS.h" #import "ReactNativeBlobUtilConst.h" #import "ReactNativeBlobUtilFileTransformer.h" -#import "IOS7Polyfill.h" @import AssetsLibrary; #import @@ -381,7 +380,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/ReactNativeBlobUtilReqBuilder.m b/ios/ReactNativeBlobUtilReqBuilder.m index 4eaf060ef..c759ce390 100644 --- a/ios/ReactNativeBlobUtilReqBuilder.m +++ b/ios/ReactNativeBlobUtilReqBuilder.m @@ -11,7 +11,6 @@ #import "ReactNativeBlobUtilNetwork.h" #import "ReactNativeBlobUtilConst.h" #import "ReactNativeBlobUtilFS.h" -#import "IOS7Polyfill.h" #if __has_include() #import @@ -151,7 +150,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/ReactNativeBlobUtilRequest.m b/ios/ReactNativeBlobUtilRequest.m index 3de37a70c..43059fcd7 100644 --- a/ios/ReactNativeBlobUtilRequest.m +++ b/ios/ReactNativeBlobUtilRequest.m @@ -13,7 +13,6 @@ #import "ReactNativeBlobUtilFileTransformer.h" #import "ReactNativeBlobUtilReqBuilder.h" -#import "IOS7Polyfill.h" #import @@ -222,20 +221,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 = [ReactNativeBlobUtilFS getTempPath:taskId withExtension:nil]; @@ -293,7 +292,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;