Skip to content

Commit abc10c5

Browse files
committed
🔖 v1.4.2
1 parent dec7d12 commit abc10c5

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

sourcelink.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sourcelink.js.LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
*
33
* Copyright (c) 2025 Praba Ponnambalam
4-
* Version: 1.4.1
4+
* Version: 1.4.2
55
* Released under the MIT License.
66
*
77
*/

sourcelinkdev.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
217217
}
218218
};
219219

220+
const validateEmail = (email) => {
221+
// Basic email validation regex that checks for:
222+
// - At least one character before @
223+
// - @ symbol
224+
// - At least one character after @ (domain name)
225+
// - At least one dot after @ with characters on both sides
226+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
227+
return emailRegex.test(email);
228+
};
229+
220230
const handleEmailInputs = () => {
221231
const emailInputs = document.querySelectorAll(
222232
'input[type="email"], input[name^="email"], input[name*="mail"]',
@@ -226,7 +236,8 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
226236
emailInput.addEventListener('blur', async () => {
227237
const email = emailInput.value.trim();
228238

229-
if (email) {
239+
if (email && validateEmail(email)) {
240+
// Only proceed if email is valid
230241
const msSourceInfoCookie = getCookie(COOKIE_NAME);
231242

232243
if (msSourceInfoCookie) {
@@ -251,6 +262,8 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
251262
console.error('Error processing email update:', error);
252263
}
253264
}
265+
} else if (email && !validateEmail(email)) {
266+
console.log('❌ SourceLink: Invalid email format');
254267
}
255268
});
256269
});

0 commit comments

Comments
 (0)