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
});
}