From 0ba6177d5ed068191fcc823cb717adf82df4d153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20NICOLAS=20=28ccjmne=29?= Date: Wed, 22 May 2024 05:36:48 +0200 Subject: [PATCH] Ensure .pdf extension for generated document --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 18ef255..4e15773 100644 --- a/src/index.js +++ b/src/index.js @@ -44,7 +44,7 @@ export function use(puppeteer) { const { filename, options } = parseRequest(request); const res = await print({ htmlContents: request.body, browser, options }); await browser.close(); - response.attachment(`${filename}`).send(res); + response.attachment(filename.replace(/(?:\.pdf)?$/, '.pdf')).send(res); }); app.post('/multiple', cors(), async (request, response) => {