Skip to content

Commit 197342d

Browse files
Fixed
1 parent 01d047a commit 197342d

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/components/Card.tsx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const Card = ({
2828
}, [isSelected]);
2929

3030
const handleDownload = async (paper: Paper) => {
31-
3231
const extension = paper.finalUrl.split(".").pop();
3332
const fileName = `${extractBracketContent(paper.subject)}-${paper.exam}-${paper.slot}-${paper.year}.${extension}`;
3433
await downloadFile(paper.finalUrl, fileName);
@@ -40,23 +39,16 @@ const Card = ({
4039
}
4140

4241
async function downloadFile(url: string, filename: string) {
43-
if (/Mobi|Android/i.test(navigator.userAgent)) {
44-
window.location.href = url;
45-
} else {
46-
try {
47-
const response = await axios.get(url, { responseType: "blob" });
48-
const blob = new Blob([response.data]);
49-
const link = document.createElement("a");
50-
link.href = window.URL.createObjectURL(blob);
51-
link.download = filename;
52-
53-
document.body.appendChild(link);
54-
link.click();
55-
document.body.removeChild(link);
56-
window.URL.revokeObjectURL(link.href);
57-
} catch (error) {
58-
console.error("Error downloading file:", error);
59-
}
42+
try {
43+
const response = await axios.get(url, { responseType: "blob" });
44+
const blob = new Blob([response.data]);
45+
const link = document.createElement("a");
46+
link.href = window.URL.createObjectURL(blob);
47+
link.download = filename;
48+
link.click();
49+
window.URL.revokeObjectURL(link.href);
50+
} catch (error) {
51+
console.error("Error downloading file:", error);
6052
}
6153
}
6254

0 commit comments

Comments
 (0)