From 6ad70b05656e96a99bcc5fdcfe8d763518362e7c Mon Sep 17 00:00:00 2001 From: grimhilt <107760093+grimhilt@users.noreply.github.com> Date: Tue, 3 Jan 2023 07:53:33 +0100 Subject: [PATCH] Fix export with attachments on formats txt and json (#9851) * set file extension to .zip when needed * Apply prettier formatting Co-authored-by: grimhilt --- src/utils/exportUtils/Exporter.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 340e04363c..eb31d5f863 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -92,7 +92,7 @@ export default abstract class Exporter { protected async downloadZIP(): Promise { const filename = this.destinationFileName; - const filenameWithoutExt = filename.substring(0, filename.length - 4); // take off the .zip + const filenameWithoutExt = filename.substring(0, filename.lastIndexOf(".")); // take off the extension const { default: JSZip } = await import("jszip"); const zip = new JSZip(); @@ -103,8 +103,7 @@ export default abstract class Exporter { for (const file of this.files) zip.file(filenameWithoutExt + "/" + file.name, file.blob); const content = await zip.generateAsync({ type: "blob" }); - - saveAs(content, filename); + saveAs(content, filenameWithoutExt + ".zip"); } protected cleanUp(): string {