feat(SearchCSDbNG): enhance image fetching by resolving links and updating file extension handling

This commit is contained in:
Jaime Idolpx 2026-06-16 16:49:22 -04:00
parent 30c96b8428
commit 588895d851

View File

@ -175,11 +175,13 @@ export default function SearchCSDbNG({ config, setConfig, onClose }: SearchCSDbN
if (release?.ScreenShot?.[0]) {
setMountProgress(p => p && { ...p, phase: 'image' });
try {
const imgRes = await fetch(release.ScreenShot[0]);
let imgPath = release.ScreenShot[0];
try { imgPath = new URL(imgPath).pathname; } catch { /* already a path */ }
const imgRes = await fetch(resolveLink(imgPath));
if (imgRes.ok) {
const imgData = await imgRes.arrayBuffer();
const mainBase = fname.replace(/\.[^.]+$/, '');
const imgExt = release.ScreenShot[0].split('.').pop()?.split('?')[0]?.toLowerCase() ?? 'png';
const imgExt = imgPath.split('.').pop()?.split('?')[0]?.toLowerCase() ?? 'png';
await putFileContents(joinPath(DOWNLOAD_DIR, `${mainBase}.${imgExt}`), imgData);
}
} catch { /* non-fatal */ }