From b42fa362b3e68f70a61a2bbf808c162f0c62a897 Mon Sep 17 00:00:00 2001 From: Appaji <52322531+CITIZENDOT@users.noreply.github.com> Date: Sat, 1 Jun 2024 02:11:09 +0530 Subject: [PATCH] Update email regex to more accurate one (#10284) --- packages/common/src/config.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/common/src/config.ts b/packages/common/src/config.ts index 83fa4595b1..1c38bdc794 100644 --- a/packages/common/src/config.ts +++ b/packages/common/src/config.ts @@ -29,8 +29,12 @@ Ethereal Engine. All Rights Reserved. const localBuildOrDev = globalThis.process.env.APP_ENV === 'development' || globalThis.process.env.VITE_LOCAL_BUILD === 'true' +// https://fightingforalostcause.net/content/misc/2006/compare-email-regex.php +const EMAIL_REGEX = + /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i + export function validateEmail(email: string): boolean { - return /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(email) + return EMAIL_REGEX.test(email) } export function validatePhoneNumber(phone: string): boolean {