mirror of
https://github.com/strapi/strapi.git
synced 2025-11-22 13:11:55 +00:00
fix: improve path match on check if folder is movable
This commit is contained in:
parent
a1a2453c15
commit
4870920918
@ -75,7 +75,11 @@ const validateMoveFoldersNotInsideThemselvesSchema = yup
|
|||||||
});
|
});
|
||||||
|
|
||||||
const unmovableFoldersNames = folders
|
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);
|
.map((f) => f.name);
|
||||||
if (unmovableFoldersNames.length > 0) {
|
if (unmovableFoldersNames.length > 0) {
|
||||||
return this.createError({
|
return this.createError({
|
||||||
|
|||||||
@ -78,7 +78,11 @@ const validateUpdateFolderSchema = (id) =>
|
|||||||
|
|
||||||
if (!destinationFolder || !currentFolder) return true;
|
if (!destinationFolder || !currentFolder) return true;
|
||||||
|
|
||||||
return !destinationFolder.path.startsWith(currentFolder.path);
|
const isUnMovable =
|
||||||
|
destinationFolder.path === currentFolder.path ||
|
||||||
|
destinationFolder.path.startsWith(`${currentFolder.path}/`);
|
||||||
|
|
||||||
|
return !isUnMovable;
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user