Skip to content

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

refactor: streamline account path handling in PAM components

Victor Santosc5169217a4b3
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
index 4d70a0ae40..eafdfe5f96 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
@@ -31,9 +31,8 @@ export const PamAccessAccountModal = ({
let fullAccountPath = account?.name ?? "";
if (accountPath) {
- let path = accountPath;
- if (path.startsWith("/")) path = path.slice(1);
- fullAccountPath = `${path}/${account?.name}`;
+ const path = accountPath.replace(/^\/+|\/+$/g, "");
+ fullAccountPath = `${path}/${account?.name ?? ""}`;
}
const isDurationValid = useMemo(() => duration && ms(duration || "1s") > 0, [duration]);
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountsTable.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountsTable.tsx
index d198847b9e..f19a1a308a 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountsTable.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountsTable.tsx
@@ -430,8 +430,7 @@ export const PamAccountsTable = ({ projectId }: Props) => {
let fullAccountPath = e?.name;
const folderPath = e.folderId ? folderPaths[e.folderId] : undefined;
if (folderPath) {
- let path = folderPath;
- if (path.startsWith("/")) path = path.slice(1);
+ const path = folderPath.replace(/^\/+|\/+$/g, "");
fullAccountPath = `${path}/${e?.name}`;
}