qwen-code/packages/web-shell/client/utils/cssUrlVar.ts
Edenman 802c382ce1
feat(web-shell): support icon chips for mention tags (#6337)
Co-authored-by: 克竟 <dingbingzhi.dbz@alibaba-inc.com>
2026-07-05 13:25:32 +00:00

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;
}