@samitouri / QOSami-HFS / commits / 3f0ebb73

fix: chrome can't download files with comma in the name #1020

Massimo Melina committed Jun 15, 2025 at 15:51 UTC 3f0ebb735b50b63e1f9a4885d3c3d01ca35c2573
1 file changed +1 -1
src/serveFile.ts
+1 -1
@@ -34,7 +34,7 @@ export function forceDownload(ctx: Koa.Context, name: string) {
34 export function disposition(ctx: Koa.Context, name: string, forceDownload=false) {
35 // ctx.attachment is not working well on Windows. Eg: for file "èÖ.txt" it is producing `Content-Disposition: attachment; filename="??.txt"`. Koa uses module content-disposition, that actually produces a better result anyway: ``
36 ctx.set('Content-Disposition', (forceDownload ? 'attachment; ' : '')
37 - + `filename="${toAsciiEquivalent(name)}"; filename*=UTF-8''${encodeURI(name).replace(/#/g, '%23')}`)
37 + + `filename="${toAsciiEquivalent(name)}"; filename*=UTF-8''${encodeURIComponent(name)}`)
38 }
39
40 export async function serveFileNode(ctx: Koa.Context, node: VfsNode) {