27 lines
744 B
TypeScript
27 lines
744 B
TypeScript
const EMAIL_RE =
|
|
/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
|
|
const IGNORE_EMAILS = new Set([
|
|
"example@example.com",
|
|
"email@example.com",
|
|
"you@example.com",
|
|
"noreply@himalayas.app",
|
|
"hello@remotive.io",
|
|
"hello@remotive.com",
|
|
"nom@exemple.fr",
|
|
]);
|
|
|
|
export function extractEmails(...texts: string[]): string[] {
|
|
const found = new Set<string>();
|
|
for (const text of texts) {
|
|
for (const match of text.match(EMAIL_RE) ?? []) {
|
|
const email = match.toLowerCase();
|
|
if (IGNORE_EMAILS.has(email)) continue;
|
|
if (email.endsWith(".png") || email.endsWith(".jpg")) continue;
|
|
if (email.includes("exemple.") || email.includes("example.")) continue;
|
|
found.add(email);
|
|
}
|
|
}
|
|
return [...found];
|
|
}
|