From a7629c2c1717e666eff654022a196b52d03ccb67 Mon Sep 17 00:00:00 2001 From: Nick Frasser <1693461+nfrasser@users.noreply.github.com> Date: Tue, 3 Dec 2024 23:59:38 -0500 Subject: [PATCH] Don't allow apostrophe in URLs (#499) Fixes #488, should end URL if encountered. --- packages/linkifyjs/src/parser.mjs | 1 - test/spec/linkifyjs/parser.test.mjs | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/linkifyjs/src/parser.mjs b/packages/linkifyjs/src/parser.mjs index 35a5206..7bb4ab5 100644 --- a/packages/linkifyjs/src/parser.mjs +++ b/packages/linkifyjs/src/parser.mjs @@ -50,7 +50,6 @@ 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 f7b8124..c17318d 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,6 +262,11 @@ 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],