From de5eca19a5c3d82462b691b8831034985c98a847 Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 20 Jan 2025 19:30:11 +0600 Subject: [PATCH] api/utils: replace redirectStatuses array with a set Co-authored-by: jj --- api/src/misc/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/misc/utils.js b/api/src/misc/utils.js index 6bc72176..9978ceed 100644 --- a/api/src/misc/utils.js +++ b/api/src/misc/utils.js @@ -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);