diff --git a/web/templates/index.html b/web/templates/index.html index 1979b56..7d1d645 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -1716,6 +1716,14 @@ async function saveConfig(showNotification = true) { } } +// Helper function to extract filename from Content-Disposition header +function getFilenameFromResponse(resp) { + const contentDisposition = resp.headers.get('content-disposition'); + if (!contentDisposition) return null; + const matches = contentDisposition.match(/filename="?([^"]+)"?/); + return matches && matches[1] ? matches[1] : null; +} + async function exportCSV() { if (cart.length === 0) return; @@ -1740,7 +1748,7 @@ async function exportCSV() { const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; - a.download = (configName || 'config') + '.csv'; + a.download = getFilenameFromResponse(resp) || (configName || 'config') + '.csv'; a.click(); window.URL.revokeObjectURL(url); } catch(e) { @@ -1993,7 +2001,7 @@ async function exportCSVWithCustomPrice() { const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; - a.download = (configName || 'config') + '.csv'; + a.download = getFilenameFromResponse(resp) || (configName || 'config') + '.csv'; a.click(); window.URL.revokeObjectURL(url); } catch(e) {