refactor(sanitizeAttributeNames): use a ternary operator

This commit is contained in:
Panagiotis Papadopoulos 2025-01-02 16:38:51 +01:00
parent afb91f82e1
commit 1053da3e40

View File

@ -1,13 +1,8 @@
export default function sanitizeAttributeName(origName: string) {
let fixedName: string;
if (origName === '') {
fixedName = "unnamed";
}
else {
const fixedName = (origName === '')
? "unnamed"
: origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
// any not allowed character should be replaced with underscore
fixedName = origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
}
return fixedName;
}