Skip to content

Commit

Permalink
api/utils: replace redirectStatuses array with a set
Browse files Browse the repository at this point in the history
Co-authored-by: jj <[email protected]>
  • Loading branch information
wukko and dumbmoron authored Jan 20, 2025
1 parent cd0a2a4 commit de5eca1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/src/misc/utils.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit de5eca1

Please sign in to comment.