diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index a5e2ce0..2004380 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -39,6 +39,7 @@ export { convertIconSetInfo } from './icon-set/convert-info'; export { iconToSVG } from './svg/build'; export { replaceIDs } from './svg/id'; export { calculateSize } from './svg/size'; +export { encodeSvgForCss } from './svg/encode-svg-for-css'; // Colors export { colorKeywords } from './colors/keywords'; @@ -53,7 +54,7 @@ export type { IconifyLoaderOptions, InlineCollection, } from './loader/types'; -export { encodeCssSvg, mergeIconProps } from './loader/utils'; +export { mergeIconProps } from './loader/utils'; export { loadIcon } from './loader/loader'; export { FileSystemIconLoader } from './loader/loaders'; export { getCustomIcon } from './loader/custom'; diff --git a/packages/utils/src/loader/utils.ts b/packages/utils/src/loader/utils.ts index 5c00fc7..426d2f2 100644 --- a/packages/utils/src/loader/utils.ts +++ b/packages/utils/src/loader/utils.ts @@ -31,14 +31,3 @@ export async function mergeIconProps( `${replacement}${Object.keys(props).map((p) => `${p}="${props[p]}"`).join(' ')}` ); } - -// https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0 -export function encodeCssSvg(svg: string): string { - return svg.replace(/"/g, '\'') - .replace(/%/g, '%25') - .replace(/#/g, '%23') - .replace(/{/g, '%7B') - .replace(/}/g, '%7D') - .replace(//g, '%3E') -} diff --git a/packages/utils/src/svg/encode-svg-for-css.ts b/packages/utils/src/svg/encode-svg-for-css.ts new file mode 100644 index 0000000..8ddabe9 --- /dev/null +++ b/packages/utils/src/svg/encode-svg-for-css.ts @@ -0,0 +1,10 @@ +// https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0 +export function encodeSvgForCss(svg: string): string { + return svg.replace(/"/g, '\'') + .replace(/%/g, '%25') + .replace(/#/g, '%23') + .replace(/{/g, '%7B') + .replace(/}/g, '%7D') + .replace(//g, '%3E') +}