refactor: streamline account path handling in PAM components

- Updated PamAccessAccountModal and PamAccountsTable to simplify account path construction by removing leading and trailing slashes.
- Enhanced readability and consistency in path handling across components.
This commit is contained in:
Victor Santos
2025-12-05 17:09:59 -03:00
parent 6db5188b36
commit c5169217a4
2 changed files with 3 additions and 5 deletions

View File

@@ -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]);

View File

@@ -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}`;
}