Browse Source

Fix IOS app crash issue when redirect URL is empty

Ben Hsieh 8 years ago
parent
commit
bc027b10b8
1 changed files with 4 additions and 2 deletions
  1. 4
    2
      src/ios/RNFetchBlobNetwork.m

+ 4
- 2
src/ios/RNFetchBlobNetwork.m View File

147
     self.options = options;
147
     self.options = options;
148
     isIncrement = [options valueForKey:@"increment"] == nil ? NO : [[options valueForKey:@"increment"] boolValue];
148
     isIncrement = [options valueForKey:@"increment"] == nil ? NO : [[options valueForKey:@"increment"] boolValue];
149
     redirects = [[NSMutableArray alloc] init];
149
     redirects = [[NSMutableArray alloc] init];
150
-    [redirects addObject:req.URL.absoluteString];
150
+    if(req.URL != nil)
151
+        [redirects addObject:req.URL.absoluteString];
151
 
152
 
152
     // set response format
153
     // set response format
153
     NSString * rnfbResp = [req.allHTTPHeaderFields valueForKey:@"RNFB-Response"];
154
     NSString * rnfbResp = [req.allHTTPHeaderFields valueForKey:@"RNFB-Response"];
574
 
575
 
575
 - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task willPerformHTTPRedirection:(NSHTTPURLResponse *)response newRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLRequest * _Nullable))completionHandler
576
 - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task willPerformHTTPRedirection:(NSHTTPURLResponse *)response newRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLRequest * _Nullable))completionHandler
576
 {
577
 {
577
-    [redirects addObject:[request.URL absoluteString]];
578
+    if(request.URL != nil)
579
+        [redirects addObject:[request.URL absoluteString]];
578
     completionHandler(request);
580
     completionHandler(request);
579
 }
581
 }
580
 
582