fix: correct redirect count increment in fetchJson (#24896)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
Kevin Zhao
2026-04-14 04:45:52 +08:00
committed by GitHub
parent 050c30330e
commit 24f9ec51d2
2 changed files with 7 additions and 1 deletions

View File

@@ -31,7 +31,11 @@ export async function fetchJson<T>(
if (!res.headers.location) {
return reject(new Error('No location header in redirect response'));
}
fetchJson<T>(res.headers.location, redirectCount++)
res.resume();
fetchJson<T>(
new URL(res.headers.location, url).toString(),
redirectCount + 1,
)
.then(resolve)
.catch(reject);
return;