Skip to content

Commit

Permalink
fix (backend): check redirect url
Browse files Browse the repository at this point in the history
  • Loading branch information
naskya authored and atsu1125 committed Mar 30, 2024
1 parent 8c8b906 commit 6583225
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/backend/src/misc/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ export async function getResponse(args: {
});

if (args.redirect === 'manual' && [301, 302, 307, 308].includes(res.status)) {
if (!isValidUrl(res.url)) {
throw new StatusError('Invalid URL', 400);
}
return res;
}

if (!res.ok) {
throw new StatusError(`${res.status} ${res.statusText}`, res.status, res.statusText);
}

if (res.redirected && !isValidUrl(res.url)) {
throw new StatusError('Invalid URL', 400);
}

return res;
}

Expand Down

0 comments on commit 6583225

Please sign in to comment.