Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix:resolved overview page add secret not working when folder not existing

Akhil Mohanc097e43a4eec
diff --git a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx
index 7addd9161b..d8a9dda807 100644
--- a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx
+++ b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx
@@ -111,9 +111,18 @@ export const SecretOverviewPage = () => {
try {
// create folder if not existing
if (secretPath !== "/") {
+ // /hello/world -> ["", "hello","world"]
const path = secretPath.split("/");
- const directory = path.slice(0, -1).join("/");
- const folderName = path.at(-1);
+ // 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) {
await createFolder({
workspaceId,