diff --git a/index.js b/index.js index e656f74..fbc7485 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ module.exports = opts => { const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*'; const tld = `(?:\\.${opts.strict ? '(?:[a-z\\u00a1-\\uffff]{2,})' : `(?:${tlds.sort((a, b) => b.length - a.length).join('|')})`})\\.?`; const port = '(?::\\d{2,5})?'; - const path = '(?:[/?#][^\\s"]*)?'; + const path = '(?:[/?#][^\\s"\']*)?'; const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld})${port}${path}`; return opts.exact ? new RegExp(`(?:^${regex}$)`, 'i') : new RegExp(regex, 'ig'); diff --git a/test.js b/test.js index 525380c..2ba52bd 100644 --- a/test.js +++ b/test.js @@ -73,7 +73,8 @@ test('match URLs in text', t => { example.com with path [and another](https://another.example.com) and - Foo //bar.net/?q=Query with spaces + Foo //bar.net/?q=Query with spaces,license/ + background: url('http://example.com/pic.jpg'); height: 100px; `; t.deepEqual([ @@ -81,7 +82,8 @@ test('match URLs in text', t => { 'http://example.com', 'http://example.com/with-path', 'https://another.example.com', - '//bar.net/?q=Query' + '//bar.net/?q=Query', + 'http://example.com/pic.jpg' ], fixture.match(m())); });