From b9a014b5c72f411d04d7c073c49afd8cbdd0c6ef Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:23:41 +0000 Subject: [PATCH] Update downloader.js --- src/main/resources/static/js/downloader.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/resources/static/js/downloader.js b/src/main/resources/static/js/downloader.js index ac4f986e..bab75025 100644 --- a/src/main/resources/static/js/downloader.js +++ b/src/main/resources/static/js/downloader.js @@ -167,6 +167,19 @@ } } + function getFilenameFromContentDisposition(contentDisposition) { + let filename; + + if (contentDisposition && contentDisposition.indexOf("attachment") !== -1) { + filename = decodeURIComponent(contentDisposition.split("filename=")[1].replace(/"/g, "")).trim(); + } else { + // If the Content-Disposition header is not present or does not contain the filename, use a default filename + filename = "download"; + } + + return filename; + } + async function handleJsonResponse(response) { const json = await response.json(); const errorMessage = JSON.stringify(json, null, 2);