Skip to content

Commit c516921

Browse files
author
Victor Santos
committed
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.
1 parent 6db5188 commit c516921

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export const PamAccessAccountModal = ({
3131

3232
let fullAccountPath = account?.name ?? "";
3333
if (accountPath) {
34-
let path = accountPath;
35-
if (path.startsWith("/")) path = path.slice(1);
36-
fullAccountPath = `${path}/${account?.name}`;
34+
const path = accountPath.replace(/^\/+|\/+$/g, "");
35+
fullAccountPath = `${path}/${account?.name ?? ""}`;
3736
}
3837

3938
const isDurationValid = useMemo(() => duration && ms(duration || "1s") > 0, [duration]);

frontend/src/pages/pam/PamAccountsPage/components/PamAccountsTable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ export const PamAccountsTable = ({ projectId }: Props) => {
430430
let fullAccountPath = e?.name;
431431
const folderPath = e.folderId ? folderPaths[e.folderId] : undefined;
432432
if (folderPath) {
433-
let path = folderPath;
434-
if (path.startsWith("/")) path = path.slice(1);
433+
const path = folderPath.replace(/^\/+|\/+$/g, "");
435434
fullAccountPath = `${path}/${e?.name}`;
436435
}
437436

0 commit comments

Comments
 (0)