Skip to content

#286: Emulator UI should not connect to 0.0.0.0 for emulators - #312

Merged
yuchenshi merged 2 commits into
firebase:masterfrom
gautamsingal:gautamsingal/task/286-wsl2-issue
Jun 18, 2020
Merged

yuchenshi merged 2 commits into
firebase:masterfrom
gautamsingal:gautamsingal/task/286-wsl2-issue

Conversation

@gautamsingal

Copy link
Copy Markdown
Contributor

Description:
- Added check whether info.host is not 0.0.0.0 or ::
- If it is present, then update the host with localhost else it remains same
- Pass the new value to hostAndPort

Description:
    - Added check whether info.host is not 0.0.0.0 or ::
    - If it is present, then update the host with localhost else it remains same
    - Pass the new value to hostAndPort

@yuchenshi yuchenshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! This looks good, but one small nit: please use 127.0.0.1 for IPv4 and ::1 for IPv6 instead of localhost.

The reason is that localhost may be mapped to both on the hosts file and may differ on each device. IP addresses are more direct and uniformly handled.

@gautamsingal

Copy link
Copy Markdown
Contributor Author

@yuchenshi Will this be good?
const host = info.host === '0.0.0.0' || info.host === '::' ? info.host === '0.0.0.0' ? '127.0.0.1' : '::1' : info.host;

@yuchenshi

Copy link
Copy Markdown
Member

const host = info.host === '0.0.0.0' || info.host === '::' ? info.host === '0.0.0.0' ? '127.0.0.1' : '::1' : info.host;

That is logically correct, but for let's stay away from chained ternaries for clarity. I suggest:

let host = info.host;
if (host === '0.0.0.0') {
  host = '127.0.0.1';
} else if (host === '::') {
  host = '::1';
}

Description:
    - Added check whether info.host is not 0.0.0.0 or ::
    - If it is present, then update the host with localhost else it remains same
    - Pass the new value to hostAndPort
@gautamsingal

Copy link
Copy Markdown
Contributor Author

@yuchenshi Okay 😁

@yuchenshi
yuchenshi merged commit bdb1933 into firebase:master Jun 18, 2020
@yuchenshi

Copy link
Copy Markdown
Member

This will be included in the next release. Cheers!

@gautamsingal

Copy link
Copy Markdown
Contributor Author

Great! Thanks @yuchenshi . Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants