(url: string | undefined, allowedHosts: string[] | undefined)
| 380 | } |
| 381 | |
| 382 | function validateAllowedHosts(url: string | undefined, allowedHosts: string[] | undefined) { |
| 383 | if (typeof url === 'string') { |
| 384 | const parsedUrl = resolveUrl(url); |
| 385 | if (parsedUrl !== null) { |
| 386 | const hostname = parsedUrl.hostname; |
| 387 | const allowedHostsSet: ReadonlySet<string> = new Set(allowedHosts); |
| 388 | if (!isHostAllowed(hostname, allowedHostsSet)) { |
| 389 | throw new RuntimeError( |
| 390 | RuntimeErrorCode.HOST_NOT_ALLOWED, |
| 391 | typeof ngDevMode === 'undefined' || ngDevMode |
| 392 | ? `Host ${url} is not allowed. You can configure \`allowedHosts\` option.` |
| 393 | : url, |
| 394 | ); |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Checks if the hostname is allowed. |
no test coverage detected
searching dependent graphs…