From 980e613a7bcf0c1d7e2ab6de4db7f11d52574f3a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 29 Mar 2023 07:43:40 -0400 Subject: [PATCH] fix: Download as Markdown should use .md extension closes #5113 --- server/routes/api/documents/documents.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 1042d2ec0..b8258c3c6 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -530,12 +530,17 @@ router.post( } if (contentType !== "application/json") { + // Override the extension for Markdown as it's incorrect in the mime-types + // library until a new release > 2.1.35 + const extension = + contentType === "text/markdown" ? "md" : mime.extension(contentType); + ctx.set("Content-Type", contentType); ctx.set( "Content-Disposition", `attachment; filename="${slugify( document.titleWithDefault - )}.${mime.extension(contentType)}"` + )}.${extension}"` ); ctx.body = content; return;