From f34a49e19c59036b320c037e80396afa2aaf0c0e Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Fri, 22 Mar 2024 13:40:43 +0530 Subject: [PATCH] fix: [SIG-570]: handle case where - being present in the key (#4735) --- frontend/src/hooks/queryBuilder/useTag.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/hooks/queryBuilder/useTag.ts b/frontend/src/hooks/queryBuilder/useTag.ts index 268a01e0c6..a3bbd4af05 100644 --- a/frontend/src/hooks/queryBuilder/useTag.ts +++ b/frontend/src/hooks/queryBuilder/useTag.ts @@ -74,7 +74,11 @@ export const useTag = ( const handleAddTag = useCallback( (value: string): void => { const { tagKey } = getTagToken(value); - const [key, id] = tagKey.split('-'); + const parts = tagKey.split('-'); + + // this is done to ensure that `hello-world` also gets converted to `body CONTAINS hello-world` + const id = parts[parts.length - 1]; + const key = parts.slice(0, -1).join('-'); if (id === 'custom') { const customValue = whereClauseConfig