Skip to content

Commit

Permalink
Delete ff angular
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Nov 21, 2024
1 parent 4384a1c commit a1023fd
Showing 1 changed file with 1 addition and 46 deletions.
47 changes: 1 addition & 46 deletions src/middleware.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,8 @@ export const middleware = async (request: NextRequest) => {
const url = new URL('/beta-version', request.url);
return NextResponse.redirect(url);
}

const isOwnershipPage =
request.nextUrl.pathname.startsWith('/organizer') &&
request.nextUrl.pathname.startsWith('/organizers') &&
!request.nextUrl.pathname.endsWith('/ownerships');

if (isOwnershipPage) {
const isOwnershipEnabled =
process.env.NEXT_PUBLIC_OWNERSHIP_ENABLED === 'true';

const redirectUrl = new URL(request.nextUrl);
// remove the path variables from nextjs routing
redirectUrl.searchParams.delete('params');

if (
isOwnershipEnabled &&
redirectUrl.searchParams.get('ownership') === 'true'
) {
return NextResponse.next();
}

if (
isOwnershipEnabled &&
redirectUrl.searchParams.get('ownership') !== 'true'
) {
redirectUrl.searchParams.set('ownership', 'true');
return NextResponse.redirect(redirectUrl);
}

if (!isOwnershipEnabled && redirectUrl.searchParams.has('ownership')) {
redirectUrl.searchParams.delete('ownership');
return NextResponse.redirect(redirectUrl);
}

return NextResponse.next();
}
};

export const config = {
matcher: [
'/event',
'/login',
'/organizers/:id/ownerships',
'/organizer/(.*)',
'/organizers/(.*)',
'/(.*)/ownerships',
'/search(.*)',
'/[...params]',
],
matcher: ['/event', '/login'],
};

0 comments on commit a1023fd

Please sign in to comment.