diff --git a/webmail/lib.ts b/webmail/lib.ts index b623d22..8dab969 100644 --- a/webmail/lib.ts +++ b/webmail/lib.ts @@ -242,9 +242,14 @@ const addLinks = (text: string): (HTMLAnchorElement | string)[] => { r.push(s) // If URL ends with interpunction, and next character is whitespace or end, don't // include the interpunction in the URL. - if (/[!),.:;>?]$/.test(url) && (!text || /^[ \t\r\n]/.test(text))) { - text = url.substring(url.length-1)+text - url = url.substring(0, url.length-1) + if (!text || /^[ \t\r\n]/.test(text)) { + if (/[)>][!,.:;?]$/.test(url)) { + text = url.substring(url.length-2)+text + url = url.substring(0, url.length-2) + } else if (/[)>!,.:;?]$/.test(url)) { + text = url.substring(url.length-1)+text + url = url.substring(0, url.length-1) + } } r.push(dom.a(url, attr.href(url), attr.target('_blank'), attr.rel('noopener noreferrer'))) } diff --git a/webmail/msg.js b/webmail/msg.js index 8767f1c..d0a264f 100644 --- a/webmail/msg.js +++ b/webmail/msg.js @@ -864,9 +864,15 @@ const addLinks = (text) => { r.push(s); // If URL ends with interpunction, and next character is whitespace or end, don't // include the interpunction in the URL. - if (/[!),.:;>?]$/.test(url) && (!text || /^[ \t\r\n]/.test(text))) { - text = url.substring(url.length - 1) + text; - url = url.substring(0, url.length - 1); + if (!text || /^[ \t\r\n]/.test(text)) { + if (/[)>][!,.:;?]$/.test(url)) { + text = url.substring(url.length - 2) + text; + url = url.substring(0, url.length - 2); + } + else if (/[)>!,.:;?]$/.test(url)) { + text = url.substring(url.length - 1) + text; + url = url.substring(0, url.length - 1); + } } r.push(dom.a(url, attr.href(url), attr.target('_blank'), attr.rel('noopener noreferrer'))); } diff --git a/webmail/text.js b/webmail/text.js index 9c36c00..f47dff6 100644 --- a/webmail/text.js +++ b/webmail/text.js @@ -864,9 +864,15 @@ const addLinks = (text) => { r.push(s); // If URL ends with interpunction, and next character is whitespace or end, don't // include the interpunction in the URL. - if (/[!),.:;>?]$/.test(url) && (!text || /^[ \t\r\n]/.test(text))) { - text = url.substring(url.length - 1) + text; - url = url.substring(0, url.length - 1); + if (!text || /^[ \t\r\n]/.test(text)) { + if (/[)>][!,.:;?]$/.test(url)) { + text = url.substring(url.length - 2) + text; + url = url.substring(0, url.length - 2); + } + else if (/[)>!,.:;?]$/.test(url)) { + text = url.substring(url.length - 1) + text; + url = url.substring(0, url.length - 1); + } } r.push(dom.a(url, attr.href(url), attr.target('_blank'), attr.rel('noopener noreferrer'))); } diff --git a/webmail/webmail.js b/webmail/webmail.js index aaabe4b..d02b840 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -864,9 +864,15 @@ const addLinks = (text) => { r.push(s); // If URL ends with interpunction, and next character is whitespace or end, don't // include the interpunction in the URL. - if (/[!),.:;>?]$/.test(url) && (!text || /^[ \t\r\n]/.test(text))) { - text = url.substring(url.length - 1) + text; - url = url.substring(0, url.length - 1); + if (!text || /^[ \t\r\n]/.test(text)) { + if (/[)>][!,.:;?]$/.test(url)) { + text = url.substring(url.length - 2) + text; + url = url.substring(0, url.length - 2); + } + else if (/[)>!,.:;?]$/.test(url)) { + text = url.substring(url.length - 1) + text; + url = url.substring(0, url.length - 1); + } } r.push(dom.a(url, attr.href(url), attr.target('_blank'), attr.rel('noopener noreferrer'))); }