From 1053da3e405b1a81c3a64e2fcaa60c091e15038b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 2 Jan 2025 16:38:51 +0100 Subject: [PATCH] refactor(sanitizeAttributeNames): use a ternary operator --- src/services/sanitize_attribute_name.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/services/sanitize_attribute_name.ts b/src/services/sanitize_attribute_name.ts index 075ccfd03..b1f0e6579 100644 --- a/src/services/sanitize_attribute_name.ts +++ b/src/services/sanitize_attribute_name.ts @@ -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; } \ No newline at end of file