mirror of
https://github.com/outline/outline.git
synced 2025-12-17 00:34:30 -06:00
16 lines
423 B
TypeScript
16 lines
423 B
TypeScript
/**
|
|
* Parse an email address into its local and domain parts.
|
|
*
|
|
* @param email The email address to parse
|
|
* @returns The local and domain parts of the email address, in lowercase
|
|
*/
|
|
export function parseEmail(email: string): { local: string; domain: string } {
|
|
const [local, domain] = email.toLowerCase().split("@");
|
|
|
|
if (!domain) {
|
|
throw new Error("Invalid email address");
|
|
}
|
|
|
|
return { local, domain };
|
|
}
|