18 lines
No EOL
707 B
TypeScript
18 lines
No EOL
707 B
TypeScript
/**
|
|
* Extracts and encodes the user and domain parts of an email address.
|
|
*
|
|
* This function splits the given email string into two parts: the user (local-part) and the domain.
|
|
* Each part is then Base64 encoded and returned as an object.
|
|
*
|
|
* Used for obfuscating email addresses to prevent direct exposure.
|
|
*
|
|
* @param {string} email - The email address to be processed.
|
|
* @returns {{ user: string, domain: string }} An object containing the Base64 encoded user and domain parts of the email.
|
|
*/
|
|
export const extractEmailPartsEncoded = (email: string): { user: string, domain: string } => {
|
|
const [user, domain] = email.split('@');
|
|
return {
|
|
user: btoa(user),
|
|
domain: btoa(domain)
|
|
};
|
|
} |