From 720ea82a309165a80c1edbe3a08fe916b260e106 Mon Sep 17 00:00:00 2001 From: Skye Book Date: Thu, 9 Feb 2017 13:04:41 -0500 Subject: [PATCH] Update path regex to not accept closing parens This fixes a few cases: * css url's of the format "background-image:url(http://example.com/img.jpg);" * markdown url's such as "look at [my image](http://example.com/img.jpg) blah blah" --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f9df5ce..e35527b 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ module.exports = opts => { const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*'; const tld = '(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?'; 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');