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)
pull/4566/head
Richard Hansen 2020-12-12 18:19:08 -05:00 committed by John McLear
parent 7e8de5540f
commit 7d23278ed0
2 changed files with 2 additions and 2 deletions

View File

@ -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',

View File

@ -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 () {