From 75fc733ff3b58aa3f922cf451120be507db401fa Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Tue, 27 Oct 2020 19:28:25 +0530 Subject: [PATCH] :recycle: Lowercase, remove plus from email --- src/helpers/safe-email.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/helpers/safe-email.ts b/src/helpers/safe-email.ts index 44cdd14c5..1ed513a5e 100644 --- a/src/helpers/safe-email.ts +++ b/src/helpers/safe-email.ts @@ -1 +1,8 @@ -export const safeEmail = (email: string) => email; +/** + * Converts an email address to a unqiue, safe email + * @param email - Valid email address + */ +export const safeEmail = (input: string) => { + const [user, domain] = input.split('@'); + return `${user.split('+')[0]}@${domain}`.toLowerCase(); +};