File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ module.exports = options => {
11
11
const protocol = `(?:(?:[a-z]+:)?//)${ options . strict ? '' : '?' } ` ;
12
12
const auth = '(?:\\S+(?::\\S*)?@)?' ;
13
13
const ip = ipRegex . v4 ( ) . source ;
14
- const host = '(?:(?:[a-z\\u00a1-\\uffff0-9]- *)*[a-z\\u00a1-\\uffff0-9]+)' ;
14
+ const host = '(?:(?:[a-z\\u00a1-\\uffff0-9][-_] *)*[a-z\\u00a1-\\uffff0-9]+)' ;
15
15
const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*' ;
16
16
const tld = `(?:\\.${ options . strict ? '(?:[a-z\\u00a1-\\uffff]{2,})' : `(?:${ tlds . sort ( ( a , b ) => b . length - a . length ) . join ( '|' ) } )` } )\\.?` ;
17
17
const port = '(?::\\d{2,5})?' ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ test('match exact URLs', t => {
10
10
'http://www.example.com/wpstyle/?p=364' ,
11
11
'https://www.example.com/foo/?bar=baz&inga=42&quux' ,
12
12
'http://a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com' ,
13
+ 'http://a_b.z.com' ,
13
14
'http://mw1.google.com/mw-earth-vectordb/kml-samples/gp/seattle/gigapxl/$[level]/r$[y]_c$[x].jpg' ,
14
15
'http://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body' ,
15
16
'http://www.microsoft.xn--comindex-g03d.html.irongeek.com' ,
@@ -118,6 +119,8 @@ test('do not match URLs', t => {
118
119
'http://.www.foo.bar./' ,
119
120
'http://go/ogle.com' ,
120
121
'http://foo.bar/ /' ,
122
+ 'http://a.b_z.com' ,
123
+ 'http://ab_.z.com' ,
121
124
'http://google\\.com' ,
122
125
'http://www(google.com' ,
123
126
'http://www.example.xn--overly-long-punycode-test-string-test-tests-123-test-test123/' ,
You can’t perform that action at this time.
0 commit comments