(hostname: string, allowedHosts: ReadonlySet<string>)
| 455 | * @private |
| 456 | */ |
| 457 | export function isHostAllowed(hostname: string, allowedHosts: ReadonlySet<string>): boolean { |
| 458 | if (allowedHosts.has('*') || allowedHosts.has(hostname)) { |
| 459 | return true; |
| 460 | } |
| 461 | |
| 462 | for (const allowedHost of allowedHosts) { |
| 463 | if (!allowedHost.startsWith('*.')) { |
| 464 | continue; |
| 465 | } |
| 466 | |
| 467 | const domain = allowedHost.slice(1); |
| 468 | if (hostname.endsWith(domain)) { |
| 469 | return true; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | return false; |
| 474 | } |
no test coverage detected