Skip to content

Commit

Permalink
Use proper regex for 127.* localhost detection (#8)
Browse files Browse the repository at this point in the history
* Use proper regex for 127.* localhost detection

* Shorten 127.* regexp, add one more test case for it
  • Loading branch information
devgru authored and ai committed Jul 31, 2018
1 parent 58d52ab commit 366e351
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion is-development.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function isDevelopment (url) {
return (
/^wss?:\/\/localhost/.test(url) ||
/^wss?:\/\/127\.0\.0\.1/.test(url) ||
/^wss?:\/\/127(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(url) ||
/^wss?:\/\/ip6-localhost/.test(url) ||
/^wss?:\/\/::1/.test(url) ||
/^wss?:\/\/[^/\s:]+\.dev(\/|:|$)/.test(url) ||
Expand Down
1 change: 1 addition & 0 deletions test/is-development.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function detects (base) {
it('detects localhost', function () {
detects('localhost')
detects('127.0.0.1')
detects('127.255.127.1')
})

it('detects IP6 localhost', function () {
Expand Down

0 comments on commit 366e351

Please sign in to comment.