mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-19 14:04:06 +00:00
24 lines
562 B
TypeScript
24 lines
562 B
TypeScript
import type { CSSProperties } from 'react';
|
|
|
|
export function cssUrlValue(url: string): string {
|
|
const escaped = url.replace(/["\\\n\r\f]/g, (char) => {
|
|
switch (char) {
|
|
case '"':
|
|
case '\\':
|
|
return `\\${char}`;
|
|
case '\n':
|
|
return '\\A ';
|
|
case '\r':
|
|
return '\\D ';
|
|
case '\f':
|
|
return '\\C ';
|
|
default:
|
|
return '';
|
|
}
|
|
});
|
|
return `url("${escaped}")`;
|
|
}
|
|
|
|
export function cssUrlVar(name: string, url: string): CSSProperties {
|
|
return { [name]: cssUrlValue(url) } as CSSProperties;
|
|
}
|