* Extract the raw email address from AgentMail's from_ field. * Format: "username@domain.com" or "Display Name "
(from: string)
| 351 | * Format: "username@domain.com" or "Display Name <username@domain.com>" |
| 352 | */ |
| 353 | function extractSenderEmail(from: string): string { |
| 354 | const openBracket = from.indexOf('<') |
| 355 | const closeBracket = from.indexOf('>', openBracket + 1) |
| 356 | if (openBracket !== -1 && closeBracket !== -1) { |
| 357 | return from |
| 358 | .substring(openBracket + 1, closeBracket) |
| 359 | .toLowerCase() |
| 360 | .trim() |
| 361 | } |
| 362 | return from.toLowerCase().trim() |
| 363 | } |
| 364 | |
| 365 | function extractDisplayName(from: string): string | null { |
| 366 | const openBracket = from.indexOf('<') |
no outgoing calls
no test coverage detected