Files
infocom-systems-design/node_modules/@iconify/utils/lib/svg/encode-svg-for-css.js
2025-10-03 22:27:28 +03:00

15 lines
635 B
JavaScript

import { encodeSVGforURL } from "./url.js";
/**
* Encode the `SVG` to be used on `CSS`: https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0.
*
* @param svg The `SVG` source.
*/
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 encodeSVGforURL(useSvg);
}
export { encodeSvgForCss };