Skip to content

Commit

Permalink
Refactor useFileExport hook to handle file name match more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
minai621 committed Jul 22, 2024
1 parent a35871c commit d0ba0e2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions frontend/src/hooks/useFileExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"] });
Expand Down

0 comments on commit d0ba0e2

Please sign in to comment.