fix: (regression 0.43.0) zip content had %encoded folder names

Massimo Melina committed Apr 20, 2023 at 11:36 UTC 14718e6fe3ea9bd2cd7727b952e9bdfc4dcd7a69
1 file changed +4 -4
src/zip.ts
+4 -4
@@ -22,16 +22,16 @@ export async function zipStreamFromFolder(node: VfsNode, ctx: Koa.Context) {
22 const filter = pattern2filter(String(ctx.query.search||''))
23 const walker = !list ? walkNode(node, ctx, Infinity, '', 'can_read')
24 : (async function*(): AsyncIterableIterator<VfsNode> {
25 - for await (const el of list) {
26 - const subNode = await urlToNode(el, ctx, node)
25 + for await (const uri of list) {
26 + const subNode = await urlToNode(uri, ctx, node)
27 if (!subNode)
28 continue
29 if (await nodeIsDirectory(subNode)) { // a directory needs to walked
30 if (hasPermission(subNode, 'can_list',ctx))
31 - yield* walkNode(subNode, ctx, Infinity, el + '/', 'can_read')
31 + yield* walkNode(subNode, ctx, Infinity, uri + '/', 'can_read')
32 continue
33 }
34 - let folder = dirname(el)
34 + let folder = dirname(decodeURIComponent(uri)) // decodeURI() won't account for %23=#
35 folder = folder === '.' ? '' : folder + '/'
36 yield { ...subNode, name: folder + getNodeName(subNode) } // reflect relative path in archive, otherwise way may have name-clashes
37 }