mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-22 06:21:41 +00: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,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) {
|
||||
const location = await fetch(url, {
|
||||
redirect: 'manual',
|
||||
dispatcher,
|
||||
}).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');
|
||||
}
|
||||
}).catch(() => null);
|
||||
|
|
Loading…
Reference in a new issue