From 0e1394f46fa6224defb325109d15f64335daebba Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Tue, 26 Aug 2025 16:18:41 +0100 Subject: [PATCH] Fix bad spaces --- frontend/src/utils/fileResponseUtils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/fileResponseUtils.ts b/frontend/src/utils/fileResponseUtils.ts index 6e4422099..472cccb05 100644 --- a/frontend/src/utils/fileResponseUtils.ts +++ b/frontend/src/utils/fileResponseUtils.ts @@ -10,7 +10,15 @@ export const getFilenameFromHeaders = (contentDisposition: string = ''): string | null => { const match = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/); if (match && match[1]) { - return match[1].replace(/['"]/g, ''); + const filename = match[1].replace(/['"]/g, ''); + + // Decode URL-encoded characters (e.g., %20 -> space) + try { + return decodeURIComponent(filename); + } catch (error) { + // If decoding fails, return the original filename + return filename; + } } return null; };