From 7a2019f2d818dd20fda66f126cf9686a89f215cc Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 5 Dec 2024 22:08:25 -0300 Subject: [PATCH] Revert "Don't allow apostrophe in URLs (#499)" This reverts commit a7629c2c1717e666eff654022a196b52d03ccb67. Fix: apostrophe is a valid character in a URL --- packages/linkifyjs/src/parser.mjs | 1 + test/spec/linkifyjs/parser.test.mjs | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/linkifyjs/src/parser.mjs b/packages/linkifyjs/src/parser.mjs index 36dbf61..e84350e 100644 --- a/packages/linkifyjs/src/parser.mjs +++ b/packages/linkifyjs/src/parser.mjs @@ -50,6 +50,7 @@ export function init({ groups }) { // but cannot be the very last characters // Characters that cannot appear in the URL at all should be excluded const qsNonAccepting = [ + tk.APOSTROPHE, tk.COLON, tk.COMMA, tk.DOT, diff --git a/test/spec/linkifyjs/parser.test.mjs b/test/spec/linkifyjs/parser.test.mjs index 94c75f9..9cb1884 100644 --- a/test/spec/linkifyjs/parser.test.mjs +++ b/test/spec/linkifyjs/parser.test.mjs @@ -243,9 +243,9 @@ const tests = [ ], ['"https://surrounded.by.quotes/"', [Text, Url, Text], ['"', 'https://surrounded.by.quotes/', '"']], [ - 'More weird character in http://facebook.com/#aZ?/:@-._~!$&()*+,;= that Url', + "More weird character in http://facebook.com/#aZ?/:@-._~!$&'()*+,;= that Url", [Text, Url, Text], - ['More weird character in ', 'http://facebook.com/#aZ?/:@-._~!$&()*+,;=', ' that Url'], + ['More weird character in ', "http://facebook.com/#aZ?/:@-._~!$&'()*+,;=", ' that Url'], ], [ 'Email with a underscore is n_frasser@example.xyz asd', @@ -262,11 +262,6 @@ const tests = [ [Text, Url, Text], ["A link in '", 'singlequote.club/wat', "' extra fluff at the end"], ], - [ - "I really like http://singlequote.club's website design", - [Text, Url, Text], - ['I really like ', 'http://singlequote.club', "'s website design"], - ], [ 'Email with mailsomething dot com domain in foo@mailsomething.com', [Text, Email],