Notes/src/services/sanitize_attribute_name.ts
2025-01-09 18:07:02 +02:00

7 lines
255 B
TypeScript

export default function sanitizeAttributeName(origName: string) {
const fixedName = origName === "" ? "unnamed" : origName.replace(/[^\p{L}\p{N}_:]/gu, "_");
// any not allowed character should be replaced with underscore
return fixedName;
}