From 451dc9c024f04c964f5bc7fcc271db7a308f98a3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Feb 2025 10:45:29 +0100 Subject: [PATCH] Fix extension detection --- packages/tests/src/feeds/feeds.ts | 1 + server/core/controllers/download.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/tests/src/feeds/feeds.ts b/packages/tests/src/feeds/feeds.ts index e4ec9a0c2..b623cc4dd 100644 --- a/packages/tests/src/feeds/feeds.ts +++ b/packages/tests/src/feeds/feeds.ts @@ -210,6 +210,7 @@ describe('Test syndication feeds', () => { const res = await makeRawRequest({ url: enclosure['@_url'], expectedStatus: HttpStatusCode.OK_200 }) expect(res.headers['content-type']).to.equal('audio/mp4') + expect(res.headers['content-disposition']).to.not.exist const alternateEnclosures = xmlDoc.rss.channel.item['podcast:alternateEnclosure'] expect(alternateEnclosures).to.be.an('array') diff --git a/server/core/controllers/download.ts b/server/core/controllers/download.ts index b4e1bf1bf..0a1680bb9 100644 --- a/server/core/controllers/download.ts +++ b/server/core/controllers/download.ts @@ -33,6 +33,7 @@ import { videosDownloadValidator, videosGenerateDownloadValidator } from '../middlewares/index.js' +import { parse } from 'node:url' const lTags = loggerTagsFactory('download') @@ -252,7 +253,8 @@ async function downloadGeneratedVideoFile (req: express.Request, res: express.Re : maxResolutionFile.extname // If there is the extension, we want to simulate a "raw file" and so not send the content disposition header - if (!req.path.endsWith('.mp4') && !req.path.endsWith('.m4a')) { + const urlPath = parse(req.originalUrl).pathname + if (!urlPath.endsWith('.mp4') && !urlPath.endsWith('.m4a')) { const downloadFilename = buildDownloadFilename({ video, extname }) res.setHeader('Content-disposition', `attachment; filename="${encodeURI(downloadFilename)}`) }