fix: bad zip name if only 1 item is selected
Massimo Melina committed
Jun 21, 2023 at 23:38 UTC
81b4b7bf39e6dabcc3685eb3aa9c53a22ba8e852
1 file changed
+1
-1
src/zip.ts
+1
-1
@@ -17,7 +17,7 @@ export async function zipStreamFromFolder(node: VfsNode, ctx: Koa.Context) {
17
ctx.mime = 'zip'
18
// ctx.query.list is undefined | string | string[]
19
const list = wantArray(ctx.query.list)[0]?.split('*') // we are using * as separator because it cannot be used in a file name and doesn't need url encoding
20
- const name = list?.length === 1 ? basename(list[0]!) : getNodeName(node)
20
+ const name = list?.length === 1 ? decodeURIComponent(basename(list[0]!)) : getNodeName(node)
21
ctx.attachment((isWindowsDrive(name) ? name[0] : (name || 'archive')) + '.zip')
22
const filter = pattern2filter(String(ctx.query.search||''))
23
const walker = !list ? walkNode(node, ctx, Infinity, '', 'can_read')