···551551 else
552552 [newRequest setHTTPMethod:@"GET"];
553553554554+ /* if the new URL is not absolute, try to build one relative to the current URL */
555555+ NSURL *tURL = [NSURL URLWithString:newURL relativeToURL:[[self actualRequest] URL]];
556556+557557+ /* but if that failed, the new URL is probably absolute already */
558558+ if (tURL == nil)
559559+ tURL = [NSURL URLWithString:newURL];
560560+561561+ if (tURL == nil) {
562562+ NSLog(@"[URLInterceptor] [Tab %@] failed building URL from %ld redirect to %@", wvt.tabIndex, (long)response.statusCode, newURL);
563563+ [[self connection] cancel];
564564+ [[self client] URLProtocol:self didFailWithError:[NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:@{ ORIGIN_KEY: (self.isOrigin ? @YES : @NO )}]];
565565+ return;
566566+ }
567567+554568 /* strangely, if we pass [NSURL URLWithString:/ relativeToURL:[NSURL https://blah/asdf/]] as the URL for the new request, it treats it as just "/" with no domain information so we have to build the relative URL, turn it into a string, then back to a URL */
555555- NSURLComponents *newURLC = [[NSURLComponents alloc] initWithString:[[NSURL URLWithString:newURL relativeToURL:[[self actualRequest] URL]] absoluteString]];
569569+ NSURLComponents *newURLC = [[NSURLComponents alloc] initWithString:[tURL absoluteString]];
556570557571 /* if we have no anchor in the new location, but the original request did, we need to preserve it */
558572 if ([newURLC fragment] == nil || [[newURLC fragment] isEqualToString:@""]) {