Replace emails with mailto links.

Closes #822
This commit is contained in:
FireMasterK 2022-02-13 19:37:05 +00:00
parent eea4965974
commit 619a1d0d7e
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -161,10 +161,15 @@ const mixin = {
return timeAgo.format(time); return timeAgo.format(time);
}, },
urlify(string) { urlify(string) {
const regex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
if (!string) return ""; if (!string) return "";
return string.replace(regex, url => { const urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
const emailRegex = /([\w-\\.]+@(?:[\w-]+\.)+[\w-]{2,4})/g;
return string
.replace(urlRegex, url => {
return `<a href="${url}" target="_blank">${url}</a>`; return `<a href="${url}" target="_blank">${url}</a>`;
})
.replace(emailRegex, email => {
return `<a href="mailto:${email}">${email}</a>`;
}); });
}, },
async updateWatched(videos) { async updateWatched(videos) {