From 0382e8d37ea19c8aad65f8bfb963e40a3a825d0d Mon Sep 17 00:00:00 2001 From: Rifat Nabi Date: Fri, 22 Sep 2017 16:35:27 +1000 Subject: [PATCH] Add nested parens support, closes #23 --- lib/re.js | 2 +- test/fixtures/links.txt | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/re.js b/lib/re.js index 941f28f..236d216 100644 --- a/lib/re.js +++ b/lib/re.js @@ -51,7 +51,7 @@ module.exports = function (opts) { '(?:' + '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' + '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' + - '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' + + '\\(((?:(?!' + re.src_ZCc + '|[())]).)*|(\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)))*\\)|' + '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' + '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' + "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" + diff --git a/test/fixtures/links.txt b/test/fixtures/links.txt index 14be646..5509883 100644 --- a/test/fixtures/links.txt +++ b/test/fixtures/links.txt @@ -291,6 +291,16 @@ http://ﻡﻮﻘﻋ.ﻭﺯﺍﺭﺓ-ﺍﻼﺘﺻﺍﻼﺗ.ﻢﺻﺭ/ http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/ + +% some urls have nested parens +http://example.com/render?target=summarize(deriviative(app.numUsers),%221min%22)&title=New_Users_Per_Minute + +http://example.com/foo-(with-nested-(parens)). +http://example.com/foo-(with-nested-(parens)) + +http://example.com/(foo) (bar) +http://example.com/(foo) + % % Others... %