MCPcopy Create free account
hub / github.com/angular/angular / validateAllowedHosts

Function validateAllowedHosts

packages/platform-server/src/utils.ts:431–447  ·  view source on GitHub ↗
(url: string | undefined, allowedHosts: string[] | undefined)

Source from the content-addressed store, hash-verified

429}
430
431function 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.

Callers 2

renderModuleFunction · 0.85
renderApplicationFunction · 0.85

Calls 2

resolveUrlFunction · 0.90
isHostAllowedFunction · 0.85

Tested by

no test coverage detected