File tree Expand file tree Collapse file tree 1 file changed +1
-5
lines changed Expand file tree Collapse file tree 1 file changed +1
-5
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ import { captureException } from "@sentry/react";
22import { Language , Languages } from "src/components/locale/languages" ;
33
44export const changeLanguage = ( languageCode : Language [ "code" ] ) => {
5- // case 1: url has no language code, eg: /about / or root
6- // case 2: url has language code, eg: /en/about /ar/ or /ar
7- // case 3: url has language code, but not in the list of supported languages, eg: /es/about /es/ or /es
8-
95 let newPath = window . location . pathname ;
106 const language = Languages . find ( ( { code } ) => code === languageCode ) ;
117 if ( ! language ) {
@@ -28,5 +24,5 @@ export const changeLanguage = (languageCode: Language["code"]) => {
2824 newPath = newPath . replace ( new RegExp ( `^/${ language . code } ` ) , "" ) ;
2925 }
3026
31- window . location . assign ( newPath ) ;
27+ window . location . replace ( newPath ) ;
3228} ;
You can’t perform that action at this time.
0 commit comments