Skip to content
Browse files

Handle the case where redirect URL is relative

While trying to download an image I encountered an error:

![screen shot 2016-05-31 at 13 58 54](

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](, is allowed).
Closes #7926

Differential Revision: D3399531

Pulled By: nicklockwood

fbshipit-source-id: ffbd5e9fc55b1737a8ff6a9bcc06fb1f9f19d093
  • Loading branch information...
maartenschumacher authored and Facebook Github Bot 1 committed Jun 7, 2016
1 parent 381a005 commit 39eca05b91d0ca344db755dfefb590472485cbf7
Showing with 1 addition and 1 deletion.
  1. +1 −1 Libraries/Image/RCTImageLoader.m
@@ -397,7 +397,7 @@ - (RCTImageLoaderCancellationBlock)loadImageOrDataWithURLRequest:(NSURLRequest *

NSURL *redirectURL = [NSURL URLWithString: location];
NSURL *redirectURL = [NSURL URLWithString: location relativeToURL: request.URL];
request = [NSURLRequest requestWithURL:redirectURL];
cachedResponse = [_URLCache cachedResponseForRequest:request];

0 comments on commit 39eca05

Please sign in to comment.
You can’t perform that action at this time.