Skip to content

Commit 6bd517a

Browse files
committed
fix : 상벌점 조회 엑셀 다운 hotfix
content-disposion을 가져오지 못해 파일 이름을 서버에서 가져올 수 없음. 이 문제는 아직 해결 방법을 찾지 못해 파일 이름을 임시로 download.xlsx로 하도록 수정함
1 parent a66e094 commit 6bd517a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

services/admin/src/apis/points/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ export const useAllPointHistoryExcel = () => {
197197
async () =>
198198
await instance.get(`${router}/history/excel`, {
199199
responseType: 'blob',
200+
headers: {
201+
Accept: 'application/octet-stream',
202+
},
200203
}),
201204
{
202205
onSuccess: (res) => {
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export const getFileNameFromContentDisposition = (encodedText: string) => {
2-
let decodedText = decodeURI(encodedText);
3-
decodedText = decodedText.replace(' ', '');
4-
decodedText = decodedText.replace('attachment;filename=', '');
5-
return decodedText;
2+
const decoded = decodeURI(encodedText || '');
3+
const match = decoded.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
4+
5+
if (match && match[1]) {
6+
return match[1].replace(/['"]/g, '').trim();
7+
}
8+
return 'download.xlsx'; // fallback
69
};

0 commit comments

Comments
 (0)