mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
10 lines
313 B
TypeScript
10 lines
313 B
TypeScript
// Build a safe CSS `url("...")` token from a raw URL string.
|
|
// Quoting is required for paths containing spaces or brackets.
|
|
export function toCssUrl(url: string): string {
|
|
const escaped = url
|
|
.replace(/\\/g, "\\\\")
|
|
.replace(/"/g, '\\"')
|
|
.replace(/[\n\r\f]/g, "");
|
|
return `url("${escaped}")`;
|
|
}
|