mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-22 10:46:19 +01:00
api/utils: replace redirectStatuses array with a set
Co-authored-by: jj <log@riseup.net>
This commit is contained in:
parent
cd0a2a47c9
commit
de5eca19a5
1 changed files with 2 additions and 2 deletions
|
@ -1,11 +1,11 @@
|
||||||
const redirectStatuses = [301, 302, 303, 307, 308];
|
const redirectStatuses = new Set([301, 302, 303, 307, 308]);
|
||||||
|
|
||||||
export async function getRedirectingURL(url, dispatcher) {
|
export async function getRedirectingURL(url, dispatcher) {
|
||||||
const location = await fetch(url, {
|
const location = await fetch(url, {
|
||||||
redirect: 'manual',
|
redirect: 'manual',
|
||||||
dispatcher,
|
dispatcher,
|
||||||
}).then((r) => {
|
}).then((r) => {
|
||||||
if (redirectStatuses.includes(r.status) && r.headers.has('location')) {
|
if (redirectStatuses.has(r.status) && r.headers.has('location')) {
|
||||||
return r.headers.get('location');
|
return r.headers.get('location');
|
||||||
}
|
}
|
||||||
}).catch(() => null);
|
}).catch(() => null);
|
||||||
|
|
Loading…
Reference in a new issue