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

Function _sanitizeUrl

packages/core/src/sanitization/url_sanitizer.ts:39–48  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

37 */
38const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:\/?#]*(?:[\/?#]|$))/i;
39export function _sanitizeUrl(url: string): string {
40 url = String(url);
41 if (url.match(SAFE_URL_PATTERN)) return url;
42
43 if (typeof ngDevMode === 'undefined' || ngDevMode) {
44 console.warn(`WARNING: sanitizing unsafe URL value ${url} (see ${XSS_SECURITY_URL})`);
45 }
46
47 return 'unsafe:' + url;
48}

Callers 4

startElementMethod · 0.90
ɵɵsanitizeUrlFunction · 0.90
sanitizeMethod · 0.85

Calls 2

warnMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected