From 15504346cdd26049431f9140ca2137e008bf55d4 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Fri, 27 Oct 2023 12:16:37 +0530 Subject: [PATCH] fix: resolved nav header secret path issues --- .../src/components/navigation/NavHeader.tsx | 2 +- .../SecretOverviewPage/SecretOverviewPage.tsx | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/navigation/NavHeader.tsx b/frontend/src/components/navigation/NavHeader.tsx index d2a0461397..739c4eca85 100644 --- a/frontend/src/components/navigation/NavHeader.tsx +++ b/frontend/src/components/navigation/NavHeader.tsx @@ -131,7 +131,7 @@ export default function NavHeader({ {isFolderMode && secretPathSegments?.map((folderName, index) => { const query = { ...router.query }; - query.secretPath = secretPathSegments.slice(0, index + 1); + query.secretPath = `/${secretPathSegments.slice(0, index + 1).join("/")}`; return (
{ try { // create folder if not existing if (secretPath !== "/") { - // /hello/world -> ["", "hello","world"] - const path = secretPath.split("/"); - // if its empty string on join use and OR gate to convert to / - // /hello - const directory = - path - .slice(0, -1) - .reduce( - (prev, curr, index, arr) => prev + (index + 1 === arr.length ? curr : `/${curr}`), - "" - ) || "/"; - const folderName = path.at(-1); // world - if (folderName && directory) { + // /hello/world -> [hello","world"] + const pathSegment = secretPath.split("/").filter(Boolean); + const parentPath = `/${pathSegment.slice(0, -1).join("/")}`; + const folderName = pathSegment.at(-1); + if (folderName && parentPath) { await createFolder({ workspaceId, environment: env, - directory, + directory: parentPath, folderName }); }