Skip to content

Commit

Permalink
Improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Mar 26, 2024
1 parent 24f8afd commit e774bd3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,16 +571,19 @@ async function lookupSpaceByAPI(
if ('redirect' in data) {
if (alternative.primary) {
// Append the path to the redirect URL if it's a VA redirect
const redirect = new URL(data.redirect);
if (redirect.searchParams.has('location')) {
redirect.searchParams.set(
'location',
joinPath(
redirect.searchParams.get('location') ?? '',
alternative.extraPath,
),
);
data.redirect = redirect.toString();
// because we might have matched a shorter path and the redirect is relative to it
if (alternative.extraPath) {
const redirect = new URL(data.redirect);
if (redirect.searchParams.has('location')) {
redirect.searchParams.set(
'location',
joinPath(
redirect.searchParams.get('location') ?? '',
alternative.extraPath,
),
);
data.redirect = redirect.toString();
}
}

return data;
Expand Down

0 comments on commit e774bd3

Please sign in to comment.