2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-09 23:00:56 +00:00

chore: move encodeCssSvg to its own module

This commit is contained in:
Joaquín Sánchez Jiménez 2022-02-26 15:39:56 +01:00
parent ef22738574
commit 8b7641839e
3 changed files with 12 additions and 12 deletions

View File

@ -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';

View File

@ -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, '%3C')
.replace(/>/g, '%3E')
}

View File

@ -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, '%3C')
.replace(/>/g, '%3E')
}