(hostname: string, allowedHosts: ReadonlySet<string>)
| 406 | * @private |
| 407 | */ |
| 408 | export function isHostAllowed(hostname: string, allowedHosts: ReadonlySet<string>): boolean { |
| 409 | if (allowedHosts.has('*') || allowedHosts.has(hostname)) { |
| 410 | return true; |
| 411 | } |
| 412 | |
| 413 | for (const allowedHost of allowedHosts) { |
| 414 | if (!allowedHost.startsWith('*.')) { |
| 415 | continue; |
| 416 | } |
| 417 | |
| 418 | const domain = allowedHost.slice(1); |
| 419 | if (hostname.endsWith(domain)) { |
| 420 | return true; |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | return false; |
| 425 | } |
no test coverage detected
searching dependent graphs…