Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: making the default host 127.0.0.1 (#359)
* feat: upgrade to v2

BREAKING CHANGE: default host to ping is 127.0.0.1

* code format
  • Loading branch information
bahmutov committed Feb 27, 2023
1 parent 9df0423 commit a9e395c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit a9e395c

Please sign in to comment.