Skip to content

Commit f4ba386

Browse files
committed
refactor: update changeLanguage function to use window.location.replace for navigation
1 parent 091015b commit f4ba386

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

web/src/redux/actions/settings.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import { captureException } from "@sentry/react";
22
import { Language, Languages } from "src/components/locale/languages";
33

44
export 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
};

0 commit comments

Comments
 (0)