Browse Source

fix: add response.ok check in downloadMedia HTTP branch

Prevents saving error pages as media files when server returns non-2xx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 3 months ago
parent
commit
1d25f9f118
  1. 4
      src/utils/downloadMedia.ts

4
src/utils/downloadMedia.ts

@ -70,6 +70,10 @@ export async function downloadMedia(
if (isHttp) { if (isHttp) {
try { try {
const response = await fetch(src); const response = await fetch(src);
if (!response.ok) {
console.error(`Failed to download: ${response.status} ${response.statusText}`);
return;
}
const blob = await response.blob(); const blob = await response.blob();
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
triggerDownload(blobUrl, finalName); triggerDownload(blobUrl, finalName);

Loading…
Cancel
Save