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

feat: making the default host 127.0.0.1 #359

Merged
merged 2 commits into from Feb 27, 2023
Merged
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
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -17,6 +17,19 @@ Requires [Node](https://nodejs.org/en/) version 8.9 or above.
npm install --save-dev start-server-and-test
```

## Upgrade

### v1 to v2

If you are using just the port number, and the resolved URL `localhost:xxxx` no longer works, use the explicit `http://localhost:xxxx` instead

```
# v1
$ npx start-test 3000
# v2
$ npx start-test http://localhost:3000
```

## Use

This command is meant to be used with NPM script commands. If you have a "start server", and "test" script names for example, you can start the server, wait for a url to respond, then run tests. When the test process exits, the server is shut down.
Expand Down
6 changes: 5 additions & 1 deletion src/utils.js
Expand Up @@ -214,7 +214,11 @@ const normalizeUrl = input => {
return s
}

if (s.startsWith('localhost') || s.startsWith('127.0.0.1') || s.startsWith('0.0.0.0')) {
if (
s.startsWith('localhost') ||
s.startsWith('127.0.0.1') ||
s.startsWith('0.0.0.0')
) {
return `http://${s}`
}

Expand Down