Urara-Blog/node_modules/.pnpm-store/v3/files/12/d5adff1a08e73890c8f94718616d29cb7b83950673e6d21f481977a1f3ab07298541695b4f34787fd88de3039f472dfd3c48517ab160aa66c9e5fb499d95dd
2022-08-14 01:14:53 +08:00

12 lines
594 B
Text

function encodeSvgForCss(svg) {
let useSvg = svg.startsWith("<svg>") ? svg.replace("<svg>", "<svg >") : svg;
if (!useSvg.includes(" xmlns:xlink=") && useSvg.includes(" xlink:")) {
useSvg = useSvg.replace("<svg ", '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ');
}
if (!useSvg.includes(" xmlns=")) {
useSvg = useSvg.replace("<svg ", '<svg xmlns="http://www.w3.org/2000/svg" ');
}
return useSvg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/{/g, "%7B").replace(/}/g, "%7D").replace(/</g, "%3C").replace(/>/g, "%3E");
}
export { encodeSvgForCss };