mirror of
https://github.com/Infisical/infisical.git
synced 2026-05-02 03:02:03 -04:00
fix:resolved overview page add secret not working when folder not existing
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user