Skip to content

best way to save what you love

api/utils: replace redirectStatuses array with a set

wukkode5eca19a5c3
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);