From 4609c25435eb6d815a40831b6edde76ef5d43cf1 Mon Sep 17 00:00:00 2001 From: "alice.juan" Date: Thu, 8 Feb 2024 18:05:05 +0100 Subject: [PATCH] fix(frontend): fix property name validation --- .../src/pages/editentry/ListAllEntryProperties.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/taxonomy-editor-frontend/src/pages/editentry/ListAllEntryProperties.tsx b/taxonomy-editor-frontend/src/pages/editentry/ListAllEntryProperties.tsx index 065ca295..d6949631 100644 --- a/taxonomy-editor-frontend/src/pages/editentry/ListAllEntryProperties.tsx +++ b/taxonomy-editor-frontend/src/pages/editentry/ListAllEntryProperties.tsx @@ -71,14 +71,17 @@ const ListAllEntryProperties = ({ nodeObject, setNodeObject }) => { const validatePropertyName = (propertyName: string): boolean => { // Every property name should be in the form property_name:lang_code if (propertyName) { - const [, langCode] = propertyName.split(":"); + const words = propertyName.split(":"); + const langCode = words[words.length - 1]; if (!LanguageCodes.includes(langCode as LanguageCode)) { return false; } // Property name should not include special caracters - const pattern = /^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$/; - if (!pattern.test(propertyName)) { - return false; + for (const word of words) { + const pattern = /^[a-zA-Z0-9_]+$/; + if (!pattern.test(word)) { + return false; + } } return true; }