Skip to content

Commit

Permalink
Refactor path generation logic in DataFilesFormModal
Browse files Browse the repository at this point in the history
  • Loading branch information
van-go committed Dec 4, 2024
1 parent 8d12c24 commit 2a39834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const DataFilesFormModal = () => {
projectUrl = projectUrl.slice(0, -1);
}

const path = updatedPath ? `${projectUrl}/${updatedPath}` : projectUrl;
// Avoid appending updatedPath if it's already part of projectUrl
const path = updatedPath && !projectUrl.endsWith(updatedPath)
? `${projectUrl}/${updatedPath}`
: projectUrl;

history.replace(path);
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/redux/sagas/_custom/drp.sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function* executeOperation(
// Check if the file name has changed. If not, keep the same path
const reloadPath =
isEdit && file.name !== values.name
? newPath.replace(`/${file.name}`, `/${values.name}`)
? newPath.replace(new RegExp(`/${file.name}$`), `/${values.name}`)
: newPath;

yield call(reloadCallback, reloadPath);
Expand Down

0 comments on commit 2a39834

Please sign in to comment.