fix: improve path match on check if folder is movable

This commit is contained in:
Marc-Roig 2023-05-17 18:08:02 +02:00
parent a1a2453c15
commit 4870920918
No known key found for this signature in database
GPG Key ID: FB4E2C43A0BEE249
2 changed files with 10 additions and 2 deletions

View File

@ -75,7 +75,11 @@ const validateMoveFoldersNotInsideThemselvesSchema = yup
});
const unmovableFoldersNames = folders
.filter((folder) => destinationFolder.path.startsWith(folder.path))
.filter(
(folder) =>
destinationFolder.path === folder.path ||
destinationFolder.path.startsWith(`${folder.path}/`)
)
.map((f) => f.name);
if (unmovableFoldersNames.length > 0) {
return this.createError({

View File

@ -78,7 +78,11 @@ const validateUpdateFolderSchema = (id) =>
if (!destinationFolder || !currentFolder) return true;
return !destinationFolder.path.startsWith(currentFolder.path);
const isUnMovable =
destinationFolder.path === currentFolder.path ||
destinationFolder.path.startsWith(`${currentFolder.path}/`);
return !isUnMovable;
}
),
})