From 77210c154add1f29604478bb3805cce979e67555 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Mon, 20 Jan 2025 00:18:17 +0900 Subject: [PATCH 1/2] Update `Server#convertMarkdown` to return processed type --- src/server.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/server.ts b/src/server.ts index b2249ec7..73d04f95 100644 --- a/src/server.ts +++ b/src/server.ts @@ -88,9 +88,7 @@ export class Server extends (EventEmitter as new () => TypedEmitter { + const type = ((): ConvertType => { const queryKeys = Object.keys(query) if (queryKeys.includes('pdf')) return ConvertType.pdf @@ -104,10 +102,14 @@ export class Server extends (EventEmitter as new () => TypedEmitter TypedEmitter { + const response = async (fn: string) => { try { - const ret = await this.convertMarkdown(fn, qs) + const { result, type } = await this.convertMarkdown(fn, qs) - if (!ret.newFile) + if (!result.newFile) throw new Error('Converter must return a converted file to serve.') - const { type } = this.converter.options - // Download pptx document as an attachment if (type === ConvertType.pptx) res.attachment(`${path.basename(fn, path.extname(fn))}.pptx`) - res.type(mimeTypes[type]).end(ret.newFile.buffer) + res.type(mimeTypes[type]).end(result.newFile.buffer) } catch (e: unknown) { let errorString = 'Internal server error' From 037ee4d19efedec62bf0448734d0282e1b3d3fb5 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Mon, 20 Jan 2025 00:48:01 +0900 Subject: [PATCH 2/2] [ci skip] CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9b6267..a1cb0984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Improve LibreOffice handling in experimental `--pptx-editable` option ([#632](https://github.com/marp-team/marp-cli/pull/632)) - Detect LibreOffice automatically that was installed in Windows by Scoop ([#631](https://github.com/marp-team/marp-cli/issues/631), [#632](https://github.com/marp-team/marp-cli/pull/632)) +- Fix returning wrong file extension in concurrent requests on server mode ([#633](https://github.com/marp-team/marp-cli/issues/633), [#634](https://github.com/marp-team/marp-cli/pull/634)) ## v4.1.0 - 2025-01-15