Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix port as -1 if dev server without specifying port on Android #34705

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion Libraries/Core/setUpReactDevTools.js
Expand Up @@ -39,7 +39,10 @@ if (__DEV__) {
// Get hostname from development server (packager)
const devServer = getDevServer();
const host = devServer.bundleLoadedFromServer
? devServer.url.replace(/https?:\/\//, '').split(':')[0]
? devServer.url
.replace(/https?:\/\//, '')
.replace(/\/$/, '')
.split(':')[0]
: 'localhost';

// Read the optional global variable for backward compatibility.
Expand Down
Expand Up @@ -69,9 +69,9 @@ public void showForUrl(String url) {
return;
}

int port = parsedURL.getPort() != -1 ? parsedURL.getPort() : parsedURL.getDefaultPort();
showMessage(
context.getString(
R.string.catalyst_loading_from_url, parsedURL.getHost() + ":" + parsedURL.getPort()));
context.getString(R.string.catalyst_loading_from_url, parsedURL.getHost() + ":" + port));
}

public void showForRemoteJSEnabled() {
Expand Down
Expand Up @@ -703,7 +703,7 @@ private void resetCurrentContext(@Nullable ReactContext reactContext) {
URL sourceUrl = new URL(getSourceUrl());
String path = sourceUrl.getPath().substring(1); // strip initial slash in path
String host = sourceUrl.getHost();
int port = sourceUrl.getPort();
int port = sourceUrl.getPort() != -1 ? sourceUrl.getPort() : sourceUrl.getDefaultPort();
mCurrentContext
.getJSModule(HMRClient.class)
.setup("android", path, host, port, mDevSettings.isHotModuleReplacementEnabled());
Expand Down