fixed filename of export
authorPhiTux <redacted>
Sat, 16 Aug 2025 17:56:45 +0000 (19:56 +0200)
committerPhiTux <redacted>
Sat, 16 Aug 2025 17:56:45 +0000 (19:56 +0200)
backend/handlers/additional.go
backend/middleware/middleware.go
frontend/src/routes/(authed)/+layout.svelte

index 5920e0a517af499de0270eff3e9d581831f8ccdd..2eaed535c0c1e119959e92bb6dcc3ada8614da20 100644 (file)
@@ -1630,7 +1630,7 @@ func ExportData(w http.ResponseWriter, r *http.Request) {
        }
 
        w.Header().Set("Content-Type", "application/zip")
-       w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
+       w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
 
        // Create ZIP writer
        zipWriter := zip.NewWriter(w)
index 704403ca47c04a1607f79d374d9ee0692624ca81..7307233cad13aa61734faf723ca9dff543372218 100644 (file)
@@ -28,7 +28,8 @@ func CORS(next http.Handler) http.Handler {
                if allowed {
                        w.Header().Set("Access-Control-Allow-Origin", origin)
                        w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
-                       w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
+                       w.Header().Set("Access-Control-Expose-Headers", "Content-Disposition")
+                       w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, Content-Disposition")
                        w.Header().Set("Access-Control-Allow-Credentials", "true")
                }
 
index 1afcc5c04ba5a40db8cfb17ccf0a6022a70b620c..e4a35f34f249a50d39f9c711875776ecf950ee9a 100644 (file)
                                const url = window.URL.createObjectURL(blob);
                                const a = document.createElement('a');
                                a.href = url;
-                               a.download = `DailyTxT_Export_${localStorage.getItem('users')}.zip`;
+
+                               const contentDisposition = response.headers['content-disposition'];
+                               let filename = 'DailyTxT_Export.zip';
+                               if (contentDisposition) {
+                                       const filenameMatch = contentDisposition.match(/filename="(.+)"/);
+                                       if (filenameMatch) {
+                                               filename = filenameMatch[1];
+                                       }
+                               }
+
+                               a.download = filename;
                                document.body.appendChild(a);
                                a.click();
                                a.remove();
git clone https://git.99rst.org/PROJECT