From 61c982a2be3262f595e4b061005b35a4f94d4e6f Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Tue, 28 May 2024 05:06:43 +0400 Subject: [PATCH] url fix --- src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx b/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx index a7f22a9c7..5780f66c4 100644 --- a/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +++ b/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx @@ -23,24 +23,19 @@ export default function LocaleDropdownNavbarItem({ const secondSlashIndex = pathname.indexOf('/', firstSlashIndex + 1); if (secondSlashIndex === -1) { - // Only one slash return locale === 'en' ? pathname.substring(firstSlashIndex) : `/${locale}${pathname}`; // Correct for single slash case } else { const currentLocaleInPath = pathname.substring(1, secondSlashIndex); const isValidLocale = locales.includes(currentLocaleInPath); if (isValidLocale && locale === 'en') { - // Switch to 'en' when valid locale exists - return pathname.substring(secondSlashIndex); // Remove the locale prefix + return pathname.substring(secondSlashIndex); } else if (isValidLocale) { - // Switch between valid locales return pathname.replace(`/${currentLocaleInPath}`, `/${locale}`); } else if (locale !== 'en') { - // Add locale prefix if no valid locale and not switching to 'en' return `/${locale}${pathname}`; } else { - // Switch to 'en' with no valid locale in path - return pathname; // Return the original path + return pathname; } } }