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

normalize localhost to 127.0.0.1 #324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EndangeredMassa
Copy link
Contributor

@EndangeredMassa EndangeredMassa commented Jun 22, 2021

When using pretender, I'll sometimes see or write localhost and 127.0.0.1 in the same app. It would be handy if these were normalized to the same value.

Here's a stab at it, but I don't mind if there's a better approach. Feel free to close if this isn't worth the trouble.


I added a test, updated some existing tests, and made sure yarn test-ci still passes.

@xg-wang
Copy link
Member

xg-wang commented Jul 25, 2021

Hmmm they do not seem to be exactly the same, at least for the tests being modified. I tried window.location.host and they will differentiate the localhost vs 127.0.0.1.

I think a better place is

let host = parseURL(url).host;
where we can normalize. What do you think?

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.

None yet

2 participants