2
0
Files
cal/calcom/packages/features/auth/signup/utils/getOrgUsernameFromEmail.ts
2024-08-09 00:39:27 +02:00

12 lines
373 B
TypeScript

import slugify from "@calcom/lib/slugify";
export const getOrgUsernameFromEmail = (email: string, autoAcceptEmailDomain: string | null) => {
const [emailUser, emailDomain = ""] = email.split("@");
const username =
emailDomain === autoAcceptEmailDomain
? slugify(emailUser)
: slugify(`${emailUser}-${emailDomain.split(".")[0]}`);
return username;
};