From 7d23278ed05f6b7a60eaa61a0c7a15df922cd38d Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 12 Dec 2020 18:19:08 -0500 Subject: [PATCH] Exclude `?`, `!`, and `)` from last character of URL Now the final character in each of these example strings is no longer considered part of the URL: * Have you seen http://example.com? * Look at http://example.com! * (see http://example.com) --- src/static/js/pad_utils.js | 2 +- tests/frontend/specs/urls_become_clickable.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index 484b2aab..ccd0d677 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -63,7 +63,7 @@ const urlRegex = (() => { const urlChar = `[-:@_.,~%+/?=&#!;()$${wordCharRegex.source.slice(1, -1)}]`; // Matches a single character that should not be considered part of the URL if it is the last // character that matches urlChar. - const postUrlPunct = '[:.,;]'; + const postUrlPunct = '[:.,;?!)]'; // Schemes that must be followed by :// const withAuth = `(?:${[ '(?:x-)?man', diff --git a/tests/frontend/specs/urls_become_clickable.js b/tests/frontend/specs/urls_become_clickable.js index c84527dc..c4b28fd4 100644 --- a/tests/frontend/specs/urls_become_clickable.js +++ b/tests/frontend/specs/urls_become_clickable.js @@ -44,7 +44,7 @@ describe('urls', function () { }); describe('punctuation after URL is ignored', function () { - for (const char of ':.,;]') { + for (const char of ':.,;?!)]') { const want = 'https://etherpad.org'; const input = want + char; it(input, async function () {