14 lines
434 B
TypeScript
14 lines
434 B
TypeScript
export function extractDomainFromEmail(email: string) {
|
|
let out = "";
|
|
try {
|
|
const match = email.match(/^(?:.*?:\/\/)?.*?(?<root>[\w\-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[\/?#:]|$)/);
|
|
out = (match && match.groups?.root) ?? "";
|
|
} catch (ignore) {}
|
|
return out.split(".")[0];
|
|
}
|
|
|
|
export const extractDomainFromWebsiteUrl = process.env.NEXT_PUBLIC_WEBSITE_URL?.replace(
|
|
"https://",
|
|
""
|
|
)?.replace("http://", "") as string;
|