From 619a1d0d7e39bb15a73555c0c10a4475a1ee83ee Mon Sep 17 00:00:00 2001
From: FireMasterK <20838718+FireMasterK@users.noreply.github.com>
Date: Sun, 13 Feb 2022 19:37:05 +0000
Subject: [PATCH] Replace emails with mailto links.
Closes #822
---
src/main.js | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/main.js b/src/main.js
index 60ac8b7e..ed1e2531 100644
--- a/src/main.js
+++ b/src/main.js
@@ -161,11 +161,16 @@ const mixin = {
return timeAgo.format(time);
},
urlify(string) {
- const regex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
if (!string) return "";
- return string.replace(regex, url => {
- return `${url}`;
- });
+ const urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
+ const emailRegex = /([\w-\\.]+@(?:[\w-]+\.)+[\w-]{2,4})/g;
+ return string
+ .replace(urlRegex, url => {
+ return `${url}`;
+ })
+ .replace(emailRegex, email => {
+ return `${email}`;
+ });
},
async updateWatched(videos) {
if (window.db) {