Skip to content

Commit 9fd0d26

Browse files
committed
fix(files): Properly encode URLs when preparing ZIP download
Signed-off-by: Fabian Zwemke <[email protected]>
1 parent 5ed48e9 commit 9fd0d26

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/files/src/actions/downloadAction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ const downloadNodes = function(nodes: Node[]) {
5555
url.searchParams.append('accept', 'zip')
5656
}
5757
} else {
58-
url = new URL(nodes[0].source)
58+
url = new URL(nodes[0].encodedSource)
5959
let base = url.pathname
6060
for (const node of nodes.slice(1)) {
61-
base = longestCommonPath(base, (new URL(node.source).pathname))
61+
base = longestCommonPath(base, (new URL(node.encodedSource).pathname))
6262
}
6363
url.pathname = base
6464

6565
// The URL contains the path encoded so we need to decode as the query.append will re-encode it
66-
const filenames = nodes.map((node) => decodeURI(node.encodedSource.slice(url.href.length + 1)))
66+
const filenames = nodes.map((node) => decodeURIComponent(node.encodedSource.slice(url.href.length + 1)))
6767
url.searchParams.append('accept', 'zip')
6868
url.searchParams.append('files', JSON.stringify(filenames))
6969
}

0 commit comments

Comments
 (0)