Skip to content

Commit

Permalink
fix: 🐛 safely pulls lang from query params, defaults to english (#7662)
Browse files Browse the repository at this point in the history
Co-authored-by: Carol Sachdeva <58209918+carol-deriv@users.noreply.github.com>
  • Loading branch information
shaheer-deriv and carolsachdeva committed Feb 21, 2023
1 parent 8cc6aef commit 4a0a8dc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import moment from 'moment';
import { setDeviceDataCookie } from './Helpers/device';

const LANGUAGE_KEY = 'i18n_language';
const DEFAULT_LANGUAGE = 'EN';
const storage_key = 'client.accounts';
const store_name = 'client_store';
const eu_shortcode_regex = new RegExp('^(maltainvest|malta|iom)$');
Expand Down Expand Up @@ -409,13 +410,11 @@ export default class ClientStore extends BaseStore {
() => [this.account_settings],
() => {
const { trading_hub } = this.account_settings;
const lang_from_url = window.location.search.slice(-2);
const lang_from_url = new URLSearchParams(window.location.search).get('lang') || DEFAULT_LANGUAGE;
this.is_pre_appstore = !!trading_hub;
localStorage.setItem('is_pre_appstore', !!trading_hub);
if (lang_from_url) {
this.setPreferredLanguage(lang_from_url);
localStorage.setItem(LANGUAGE_KEY, lang_from_url);
}
this.setPreferredLanguage(lang_from_url);
LocalStore.set(LANGUAGE_KEY, lang_from_url);
}
);
// TODO: Remove this after setting trading_hub enabled for all users
Expand Down

0 comments on commit 4a0a8dc

Please sign in to comment.