diff --git a/package.json b/package.json index 9441417..c16c1bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nixamp", - "version": "0.72.0", + "version": "0.72.1", "description": "It really whips the terminal's ass. A Winamp-shaped audio player for your terminal.", "license": "MIT", "type": "module", diff --git a/src/guide-vods.ts b/src/guide-vods.ts index 21632a0..e7567df 100644 --- a/src/guide-vods.ts +++ b/src/guide-vods.ts @@ -252,7 +252,7 @@ export async function handleVods(request: IncomingMessage, response: ServerRespo return true; } // The file's own server sends it, as an attachment. - response.writeHead(302, { location: `${vod.play}&download=1`, "cache-control": "private, no-store", "referrer-policy": "no-referrer" }); + response.writeHead(302, { location: `${vod.play}&download=1&name=${encodeURIComponent(vod.name)}`, "cache-control": "private, no-store", "referrer-policy": "no-referrer" }); response.end(); return true; } diff --git a/src/library-routes.ts b/src/library-routes.ts index 754b10a..78efe55 100644 --- a/src/library-routes.ts +++ b/src/library-routes.ts @@ -263,7 +263,7 @@ export async function handleLibrary( if (itemMatch[2] === "play" && ctx.play) { // `download=1`: the same file as an attachment, named for what it is (a bought VOD download). const named = url.searchParams.get("download") === "1" - ? (item.override.title || item.title || item.path.split("/").pop()!.replace(/\.[^.]+$/, "")).replace(/[\\/:*?"<>|\x00-\x1f]/g, "").slice(0, 160) || item.id + ? (url.searchParams.get("name") || item.override.title || item.title || item.path.split("/").pop()!.replace(/\.[^.]+$/, "")).replace(/[\\/:*?"<>|\x00-\x1f]/g, "").slice(0, 160) || item.id : ""; await ctx.play(request, response, item.path, named || undefined); return true; diff --git a/test/guide-vods.test.ts b/test/guide-vods.test.ts index 6e27fd8..73a7829 100644 --- a/test/guide-vods.test.ts +++ b/test/guide-vods.test.ts @@ -162,7 +162,7 @@ test("the owner prices its own sellable file; a bought grant redirects to the fi const download = (g: string) => fetch(`${base}/api/v1/guide/vods/${vod.id}/download?grant=${g}`, { redirect: "manual" }); const ok = await download("good"); assert.equal(ok.status, 302); - assert.equal(ok.headers.get("location"), `${PLAY}&download=1`); + assert.equal(ok.headers.get("location"), `${PLAY}&download=1&name=Nosferatu`); assert.equal((await download("other")).status, 403, "a grant for another video"); assert.equal((await download("bad")).status, 403); // A member may not put a price on anything.