mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-16 10:39:50 +08:00
Handle the case where redirect URL is relative
Summary: While trying to download an image I encountered an error:  As you can see the domain name is missing from the URL. I traced it back to a method which handles redirects. It would retrieve the redirect URL from the `Location` header field, but it didn’t handle the case where `Location` contains a relative URL (which [according to the RFC spec](https://tools.ietf.org/html/rfc7231#section-7.1.2), is allowed). Closes https://github.com/facebook/react-native/pull/7926 Differential Revision: D3399531 Pulled By: nicklockwood fbshipit-source-id: ffbd5e9fc55b1737a8ff6a9bcc06fb1f9f19d093
This commit is contained in:
committed by
Facebook Github Bot 1
parent
381a0051c7
commit
39eca05b91
@@ -397,7 +397,7 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL *redirectURL = [NSURL URLWithString: location];
|
||||
NSURL *redirectURL = [NSURL URLWithString: location relativeToURL: request.URL];
|
||||
request = [NSURLRequest requestWithURL:redirectURL];
|
||||
cachedResponse = [_URLCache cachedResponseForRequest:request];
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user