2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 13:47:49 +00:00

chore(utils): add function to sanitise title prop

This commit is contained in:
Vjacheslav Trushkin 2024-07-28 09:57:18 +03:00
parent f3856ac810
commit ad7158c315
3 changed files with 14 additions and 0 deletions

View File

@ -337,6 +337,11 @@
"require": "./lib/misc/strings.cjs", "require": "./lib/misc/strings.cjs",
"import": "./lib/misc/strings.mjs" "import": "./lib/misc/strings.mjs"
}, },
"./lib/misc/title": {
"types": "./lib/misc/title.d.ts",
"require": "./lib/misc/title.cjs",
"import": "./lib/misc/title.mjs"
},
"./lib/misc/licenses": { "./lib/misc/licenses": {
"types": "./lib/misc/licenses.d.ts", "types": "./lib/misc/licenses.d.ts",
"require": "./lib/misc/licenses.cjs", "require": "./lib/misc/licenses.cjs",

View File

@ -131,3 +131,4 @@ export {
compareObjects, compareObjects,
unmergeObjects, unmergeObjects,
} from './misc/objects'; } from './misc/objects';
export { sanitiseTitleAttribute } from './misc/title';

View File

@ -0,0 +1,8 @@
/**
* Sanitises title, removing any unwanted characters that might break XML.
*
* This is a very basic funciton, not full parser.
*/
export function sanitiseTitleAttribute(content: string): string {
return content.replace(/[<>&]+/g, '');
}