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

Function escapeCssUrl

packages/common/src/directives/ng_optimized_image/url.ts:50–62  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

48}
49
50export function escapeCssUrl(input: string): string {
51 return (
52 input
53 // Backslash first — later replacements must not have their own \ escaped again.
54 .replace(/\\/g, '\\\\')
55 // \n, \r, \f and null terminate a CSS string (CSS Syntax 3 §4.3.5,
56 // https://www.w3.org/TR/css-syntax-3/#consume-string-token) and are also
57 // invalid in URLs, so stripping them is safe.
58 .replace(/[\n\r\f\0]/g, '')
59 // A bare " would close the url("...") wrapper early.
60 .replace(/"/g, '\\"')
61 );
62}

Callers 2

generatePlaceholderMethod · 0.90

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected