From a289fdd2d757c85888efaaa2bcfe06733976fd88 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 19 Jan 2024 20:19:59 +0100 Subject: fix(files): Allow to copy or move file to folder with similar name Signed-off-by: Ferdinand Thiessen --- apps/files/src/actions/moveOrCopyAction.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/files/src') diff --git a/apps/files/src/actions/moveOrCopyAction.ts b/apps/files/src/actions/moveOrCopyAction.ts index 42ae82bb261..a4e70caf37d 100644 --- a/apps/files/src/actions/moveOrCopyAction.ts +++ b/apps/files/src/actions/moveOrCopyAction.ts @@ -89,8 +89,10 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth * Do not allow as it would copy foo within itself * - node: /foo/bar.txt, destination: /foo * Allow copy a file to the same directory + * - node: "/foo/bar", destination: "/foo/bar 1" + * Allow to move or copy but we need to check with trailing / otherwise it would report false positive */ - if (destination.path.startsWith(node.path)) { + if (`${destination.path}/`.startsWith(`${node.path}/`)) { throw new Error(t('files', 'You cannot move a file/folder onto itself or into a subfolder of itself')) } -- cgit v1.2.3