From cc6cbf53e8fb902e51ed5e20e9abf4d531cd5556 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 28 May 2025 17:36:05 +0400 Subject: [PATCH] refac --- src/lib/components/common/ImagePreview.svelte | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/components/common/ImagePreview.svelte b/src/lib/components/common/ImagePreview.svelte index a714634ba..2e9ce77d5 100644 --- a/src/lib/components/common/ImagePreview.svelte +++ b/src/lib/components/common/ImagePreview.svelte @@ -107,7 +107,9 @@ const mimeType = blob.type || 'image/png'; // create file name based on the MIME type, alt should be a valid file name with extension - const fileName = alt ? `${alt}.${mimeType.split('/')[1]}` : 'download.png'; + const fileName = alt + ? `${alt.replaceAll('.', '')}.${mimeType.split('/')[1]}` + : 'download.png'; // Use FileSaver to save the blob saveAs(blob, fileName); @@ -124,7 +126,9 @@ const blobWithType = new Blob([blob], { type: mimeType }); // create file name based on the MIME type, alt should be a valid file name with extension - const fileName = alt ? `${alt}.${mimeType.split('/')[1]}` : 'download.png'; + const fileName = alt + ? `${alt.replaceAll('.', '')}.${mimeType.split('/')[1]}` + : 'download.png'; // Use FileSaver to save the blob saveAs(blobWithType, fileName); @@ -149,7 +153,9 @@ const blobWithType = new Blob([blob], { type: mimeType }); // create file name based on the MIME type, alt should be a valid file name with extension - const fileName = alt ? `${alt}.${mimeType.split('/')[1]}` : 'download.png'; + const fileName = alt + ? `${alt.replaceAll('.', '')}.${mimeType.split('/')[1]}` + : 'download.png'; // Use FileSaver to save the blob saveAs(blobWithType, fileName);