mirror of
https://github.com/iconify/iconify.git
synced 2024-12-12 05:37:49 +00:00
chore(utils): add function to sanitise title prop
This commit is contained in:
parent
f3856ac810
commit
ad7158c315
@ -337,6 +337,11 @@
|
||||
"require": "./lib/misc/strings.cjs",
|
||||
"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": {
|
||||
"types": "./lib/misc/licenses.d.ts",
|
||||
"require": "./lib/misc/licenses.cjs",
|
||||
|
@ -131,3 +131,4 @@ export {
|
||||
compareObjects,
|
||||
unmergeObjects,
|
||||
} from './misc/objects';
|
||||
export { sanitiseTitleAttribute } from './misc/title';
|
||||
|
8
packages/utils/src/misc/title.ts
Normal file
8
packages/utils/src/misc/title.ts
Normal 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, '');
|
||||
}
|
Loading…
Reference in New Issue
Block a user