Notes/src/services/sanitize_attribute_name.ts

19 lines
369 B
TypeScript
Raw Normal View History

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