Notes/apps/server/src/services/sanitize_attribute_name.ts

7 lines
255 B
TypeScript
Raw Normal View History

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