Browse Source

Add support for localhost in regex

pull/1/merge
Luke Childs 9 years ago
parent
commit
ec516da19a
  1. 2
      src/regex.js
  2. 8
      test/matches.json

2
src/regex.js

@ -13,6 +13,6 @@ const optionalSlash = `(${escapeChar}/(${notWhitespaceCommaOrDot}*)?)?`;
const endsWithButDontMatch = `(?=${WhitespaceCommaDotOrEndOfLine})`;
// Build
const regex = `(${hostname}|${ip})${optionalPortNumber}${optionalSlash}${endsWithButDontMatch}`;
const regex = `(localhost|${hostname}|${ip})${optionalPortNumber}${optionalSlash}${endsWithButDontMatch}`;
export default new RegExp(regex, 'gi');

8
test/matches.json

@ -35,6 +35,14 @@
"description": "IP address with trailing slash",
"url": "192.168.0.1/"
},
{
"description": "Localhost",
"url": "localhost"
},
{
"description": "Localhost with trailing slash",
"url": "localhost/"
},
{
"description": "Url with slug",
"url": "url.com/slug"

Loading…
Cancel
Save