From a9e395c248b6ed9f6be0704038d3d048c8ff8684 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 27 Feb 2023 07:54:45 -0500 Subject: [PATCH] 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 --- README.md | 13 +++++++++++++ src/utils.js | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d54ee9e..5e9664a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/utils.js b/src/utils.js index 94c0037..abd1a69 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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}` }