From 74b1ec2c298d51de56d3ed481c330146cda27cdf Mon Sep 17 00:00:00 2001 From: Nimish Date: Tue, 17 Sep 2024 15:29:05 +0530 Subject: [PATCH] feat: allow kebab and snake case folder names --- .../[app]/environments/[environment]/[[...path]]/page.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/app/[team]/apps/[app]/environments/[environment]/[[...path]]/page.tsx b/frontend/app/[team]/apps/[app]/environments/[environment]/[[...path]]/page.tsx index d2be14235..4b983eda3 100644 --- a/frontend/app/[team]/apps/[app]/environments/[environment]/[[...path]]/page.tsx +++ b/frontend/app/[team]/apps/[app]/environments/[environment]/[[...path]]/page.tsx @@ -526,8 +526,8 @@ export default function EnvironmentPath({ const NewFolderMenu = () => { const [name, setName] = useState('') - // Regular expression to match only alphanumeric characters - const regex = /^[a-zA-Z0-9]*$/ + // Regular expression to match only alphanumeric characters along with dashes (-) and underscores (_) + const folder_name_pattern = /^[a-zA-Z0-9_-]*$/ const closeModal = () => { setFolderMenuIsOpen(false) @@ -543,11 +543,9 @@ export default function EnvironmentPath({ } const handleUpdateName = (newName: string) => { - // Regular expression to match only alphanumeric characters - const regex = /^[a-zA-Z0-9]*$/ // Check if the new value matches the regular expression - if (regex.test(newName) || newName === '') { + if (folder_name_pattern.test(newName) || newName === '') { // Update the state if the value is alphanumeric or empty (to allow clearing the input) setName(newName) }