(url: string | undefined, allowedHosts: string[] | undefined)
| 429 | } |
| 430 | |
| 431 | function validateAllowedHosts(url: string | undefined, allowedHosts: string[] | undefined) { |
| 432 | if (typeof url === 'string') { |
| 433 | const parsedUrl = resolveUrl(url); |
| 434 | if (parsedUrl !== null) { |
| 435 | const hostname = parsedUrl.hostname; |
| 436 | const allowedHostsSet: ReadonlySet<string> = new Set(allowedHosts); |
| 437 | if (!isHostAllowed(hostname, allowedHostsSet)) { |
| 438 | throw new RuntimeError( |
| 439 | RuntimeErrorCode.HOST_NOT_ALLOWED, |
| 440 | typeof ngDevMode === 'undefined' || ngDevMode |
| 441 | ? `Host ${url} is not allowed. You can configure \`allowedHosts\` option.` |
| 442 | : url, |
| 443 | ); |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Checks if the hostname is allowed. |
no test coverage detected