From d0ba0e2f8fd425e2dd1dedfd88efc0c3c9dd978e Mon Sep 17 00:00:00 2001 From: mj Date: Tue, 23 Jul 2024 01:14:08 +0900 Subject: [PATCH] Refactor useFileExport hook to handle file name match more efficiently --- frontend/src/hooks/useFileExport.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/hooks/useFileExport.ts b/frontend/src/hooks/useFileExport.ts index 349b4272..3cc4c781 100644 --- a/frontend/src/hooks/useFileExport.ts +++ b/frontend/src/hooks/useFileExport.ts @@ -42,8 +42,7 @@ export const useFileExport = (): UseFileExportReturn => { }); const contentDisposition = response.headers["content-disposition"]; - const fileNameMatch = - contentDisposition && contentDisposition.match(/filename="?(.+)"?\s*$/i); + const fileNameMatch = contentDisposition?.match(/filename="?(.+)"?\s*$/i); const fileName = fileNameMatch ? fileNameMatch[1] : `${documentName}.${exportType}`; const blob = new Blob([response.data], { type: response.headers["content-type"] });