MCPcopy
hub / github.com/angular/angular / validateAllowedHosts

Function validateAllowedHosts

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

Source from the content-addressed store, hash-verified

380}
381
382function 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.

Callers 2

renderModuleFunction · 0.85
renderApplicationFunction · 0.85

Calls 2

resolveUrlFunction · 0.90
isHostAllowedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…