From 41ec7cd4f0d660d04367e2cdd016edc928b972d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 22 Jul 2024 11:27:53 +0200
Subject: [PATCH] fix filename generation

---
 frontend/src/components/canvas/Canvas.vue | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/frontend/src/components/canvas/Canvas.vue b/frontend/src/components/canvas/Canvas.vue
index e3f16c7..4174ce5 100644
--- a/frontend/src/components/canvas/Canvas.vue
+++ b/frontend/src/components/canvas/Canvas.vue
@@ -41,10 +41,16 @@ export default {
 
       let link = document.createElement("a");
 
-      if (window.fileName !== undefined) {
+      if (
+        window.fileName !== undefined && window.fileName !== null
+        && (typeof window.fileName === 'string' || window.fileName instanceof String)
+        && window.fileName.length >= 1
+      ) {
         link.download = window.fileName;
       } else {
-        link.download = `Generator-${new Date().toLocaleString()}.png`;
+        const date = new Date().toLocaleString();
+
+        link.download = `Generator-${date}.png`;
       }
 
       link.href = this.$refs.canvas.toDataURL();
-- 
GitLab