Reject bad redirects cleanly and ignore any icon read error

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
saphidandClaude Opus 5.5 committed 2026-09-26 20:55:41 +10:00
1 parent d145537d9a
commit 0478626061
2 files changed
+6 -3

No files matched your search

+4 -1
View File
@@ -49,7 +49,10 @@ function get(url, redirects = 5) {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
res.resume();
if (!redirects) return reject(new Error(`${url}: too many redirects`));
return resolve(get(new URL(res.headers.location, url).href, redirects - 1));
let next;
try { next = new URL(res.headers.location, url).href; }
catch { return reject(new Error(`${url}: bad redirect ${res.headers.location}`)); }
return resolve(get(next, redirects - 1));
}
if (res.statusCode !== 200) return reject(new Error(`${url}: HTTP ${res.statusCode}`));
const chunks = [];