[0.69] Use Content-Location header in bundle response as JS source URL (#37501) (#38179)

resolved: https://github.com/facebook/react-native/pull/37501
fix for https://github.com/facebook/react-native/issues/36794.
This commit is contained in:
Rob Hogan
2023-07-04 13:38:51 +01:00
committed by GitHub
parent 2407776d11
commit 367fc7ad52
2 changed files with 20 additions and 5 deletions
+11 -1
View File
@@ -312,7 +312,17 @@ static void attemptAsynchronousLoadOfBundleAtURL(
return;
}
RCTSource *source = RCTSourceCreate(scriptURL, data, data.length);
// Prefer `Content-Location` as the canonical source URL, if given, or fall back to scriptURL.
NSURL *sourceURL = scriptURL;
NSString *contentLocationHeader = headers[@"Content-Location"];
if (contentLocationHeader) {
NSURL *contentLocationURL = [NSURL URLWithString:contentLocationHeader relativeToURL:scriptURL];
if (contentLocationURL) {
sourceURL = contentLocationURL;
}
}
RCTSource *source = RCTSourceCreate(sourceURL, data, data.length);
parseHeaders(headers, source);
onComplete(nil, source);
}