Skip to content

Commit f713fb0

Browse files
committed
Allow dashes according to RFC in all domain parts except TLD. Fixes #63
1 parent c26bc75 commit f713fb0

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

lib/re.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ module.exports = function (opts) {
101101
'|' +
102102
'(?:' + re.src_pseudo_letter + ')' +
103103
'|' +
104-
// don't allow `--` in domain names, because:
105-
// - that can conflict with markdown — / –
106-
// - nobody use those anyway
107-
'(?:' + re.src_pseudo_letter + '(?:-(?!-)|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
104+
'(?:' + re.src_pseudo_letter + '(?:-|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
108105
')';
109106

110107
re.src_host =

test/fixtures/links.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,15 @@ test@google.com
302302

303303
|http://google.com|bar
304304
http://google.com
305+
306+
%
307+
% Domains with multiple dashes
308+
%
309+
310+
https://5b0ee223b312746c1659db3f--thelounge-chat.netlify.com/docs/
311+
312+
www.a--b.com
313+
314+
www.c--u.com
315+
316+
http://a---b.com/

test/fixtures/not_links.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ hppt://example.com
99
example.coma
1010
-example.coma
1111
foo.123
12-
http://a.b--c.de/ % `--` disabled, because collision possible
1312
localhost % only with protocol allowed
1413
localhost/
1514
///localhost % 3 '/' not allowed
@@ -50,4 +49,4 @@ a1.2.3.4
5049
% Not email
5150
%
5251
foo@bar % Should be at second level domain & with correct tld
53-
mailto:bar
52+
mailto:bar

0 commit comments

Comments
 (0)