Skip to content

Commit cf67427

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Trim Leading Slash in DevServerHelper (facebook#50077)
Summary: Pull Request resolved: facebook#50077 Currently, `DevServerHelper` will fetch malformed URLs if the supplied `resourcePath` has a leading slash. This diff adds a warning and automatically trims the leading slash when this happens. Changelog: [Android][Changed] - Leading slash supplied to `DevServerHelper.downloadBundleResourceFromUrlSync` will now be trimmed and emit a warning. Reviewed By: robhogan Differential Revision: D71333088 fbshipit-source-id: 636c9c6c6919d1e9d4a829ed5ae7253f829e549c
1 parent f4d2d39 commit cf67427

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ private String createBundleURL(String mainModuleID, BundleType type) {
404404
}
405405

406406
private static String createResourceURL(String host, String resourcePath) {
407+
// This is what we get for not using a proper URI library.
408+
if (resourcePath.startsWith("/")) {
409+
FLog.w(ReactConstants.TAG, "Resource path should not begin with `/`, removing it.");
410+
resourcePath = resourcePath.substring(1);
411+
}
407412
return String.format(Locale.US, "http://%s/%s", host, resourcePath);
408413
}
409414

0 commit comments

Comments
 (0)