From 8206fea921e01d6ea7165628ba38141fa2640215 Mon Sep 17 00:00:00 2001 From: zbeyens Date: Wed, 25 Dec 2024 19:19:37 +0100 Subject: [PATCH] fix --- apps/www/src/components/languages-dropdown-menu.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/www/src/components/languages-dropdown-menu.tsx b/apps/www/src/components/languages-dropdown-menu.tsx index 2cf806a4c0..cb910d59e9 100644 --- a/apps/www/src/components/languages-dropdown-menu.tsx +++ b/apps/www/src/components/languages-dropdown-menu.tsx @@ -27,9 +27,10 @@ export function LanguagesDropdownMenu() { } else { if (!pathname?.includes('cn')) return; if (pathname) { - const isHomePage = pathname.split('/').filter((p) => !!p).length === 1; - - url.pathname = isHomePage ? '/' : (pathname.split('/').at(-1) ?? '/'); + const segments = pathname.split('/').filter((p) => !!p); + const newSegments = segments.filter((segment) => segment !== 'cn'); + url.pathname = + newSegments.length > 0 ? `/${newSegments.join('/')}` : '/'; } url.searchParams.delete('locale');