Browse Source

Hostname must contain at least one char

pull/3/head
Luke Childs 9 years ago
parent
commit
5d751c2130
  1. 2
      src/regex.js
  2. 4
      test/non-matches.json

2
src/regex.js

@ -9,7 +9,7 @@ const WhitespaceCommaDotOrEndOfLine = `[${escapeChar}s,.]|$`;
const number = `[0-9]`;
// Sections
const hostname = `(${notWhitespaceOrComma}*${escapeChar}.(${validTlds}))`;
const hostname = `(${notWhitespaceOrComma}+${escapeChar}.(${validTlds}))`;
const ip = `(${number}{1,3}${escapeChar}.){3}${number}{1,3}`;
const optionalPortNumber = `(:${number}+)?`;
const optionalSlash = `(${escapeChar}/(${notWhitespaceCommaOrDot}*)?)?`;

4
test/non-matches.json

@ -14,5 +14,9 @@
{
"description": "Url with semicolon but no port number",
"url": "url.com:"
},
{
"description": "TLD with no hostname",
"url": ".com"
}
]

Loading…
Cancel
Save