mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 02:59:21 +03:00
Replaced Autolinker with simple https/email detection
This commit is contained in:
parent
f5a444aa14
commit
2f48128ff3
5 changed files with 16 additions and 32 deletions
|
|
@ -507,21 +507,13 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
|
|||
* @param {string} html
|
||||
* @returns {string}
|
||||
*/
|
||||
/*eslint-disable max-len*/
|
||||
const url = /(^|[\s\n]|\/?>)(https:\/\/[-A-Z0-9+\u0026\u2019#/%?=()~_|!:,.;]*[-A-Z0-9+\u0026#/%=~()_|])/gi,
|
||||
email = /(^|[\s\n]|\/?>)((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x21\x23-\x5b\x5d-\x7f]|\\[\x21\x23-\x5b\x5d-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x21-\x5a\x53-\x7f]|\\[\x21\x23-\x5b\x5d-\x7f])+)\]))/gi;
|
||||
export function findEmailAndLinks(html) {
|
||||
return window.Autolinker
|
||||
? window.Autolinker.link(html, {
|
||||
newWindow: true,
|
||||
stripPrefix: false,
|
||||
urls: true,
|
||||
email: true,
|
||||
mention: false,
|
||||
phone: false,
|
||||
hashtag: false,
|
||||
replaceFn: function(match) {
|
||||
return !(match && 'url' === match.getType() && match.matchedText && 0 !== match.matchedText.indexOf('http'));
|
||||
}
|
||||
})
|
||||
: html;
|
||||
return html
|
||||
.replace(url, '$1<a href="$2" target="_blank">$2</a>')
|
||||
.replace(email, '$1<a href="mailto:$2">$2</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue