Notes/src/services/sanitize_attribute_name.ts

8 lines
276 B
TypeScript
Raw Normal View History

export default function sanitizeAttributeName(origName: string) {
const fixedName = (origName === '')
? "unnamed"
: origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
2022-12-23 14:18:40 +01:00
// any not allowed character should be replaced with underscore
return fixedName;
}