(email: string, allowedEmails: string[])
| 114 | * sides, so callers don't need to normalize before calling. |
| 115 | */ |
| 116 | export function isEmailAllowed(email: string, allowedEmails: string[]): boolean { |
| 117 | const normalizedEmail = email.trim().toLowerCase() |
| 118 | const normalizedAllowed = allowedEmails.map((allowed) => allowed.trim().toLowerCase()) |
| 119 | |
| 120 | if (normalizedAllowed.includes(normalizedEmail)) { |
| 121 | return true |
| 122 | } |
| 123 | |
| 124 | const atIndex = normalizedEmail.indexOf('@') |
| 125 | if (atIndex > 0) { |
| 126 | const domain = normalizedEmail.substring(atIndex + 1) |
| 127 | if (domain && normalizedAllowed.some((allowed) => allowed === `@${domain}`)) { |
| 128 | return true |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | return false |
| 133 | } |
no outgoing calls
no test coverage detected