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

This commit is contained in:
Akhil Mohan
2023-10-26 15:14:05 +05:30
parent c0592ad904
commit c097e43a4e

View File

@@ -111,9 +111,18 @@ export const SecretOverviewPage = () => {
try { try {
// create folder if not existing // create folder if not existing
if (secretPath !== "/") { if (secretPath !== "/") {
// /hello/world -> ["", "hello","world"]
const path = secretPath.split("/"); const path = secretPath.split("/");
const directory = path.slice(0, -1).join("/"); // if its empty string on join use and OR gate to convert to /
const folderName = path.at(-1); // /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) { if (folderName && directory) {
await createFolder({ await createFolder({
workspaceId, workspaceId,