Skip to content

Commit

Permalink
fix: redirect to /en/ page from 404 for any unsupported langs + work …
Browse files Browse the repository at this point in the history
…with any lang case
  • Loading branch information
maryia-deriv committed Jun 7, 2024
1 parent 350af1e commit 2e1ca65
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/root_files/_common/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
}

var langs = {
// TODO: uncomment if we enable id, ko and pt languages
// 'id': 'id',
// 'ko': 'kr',
// 'pt': 'br|mz|ao|pt|gw|pg|cv|st',
'de': 'de|at|li',
'es': 'ar|bo|cl|co|cr|cu|do|ec|sv|gt|hn|mx|ni|pa|py|pr|es|uy|ve',
'fr': 'fr|ad|bj|bf|cf|cg|ga|gn|ml|mc|ne|sn|tg',
'id': 'id',
'it': 'it',
'ko': 'kr',
'pl': 'po',
'pt': 'br|mz|ao|pt|gw|pg|cv|st',
'ru': 'ru|ua|by|kz',
'th': 'th',
'vi': 'vn',
Expand All @@ -44,7 +45,7 @@

// redirect to /en/ page if pathname contains an unsupported language:
const supported_langs_regex = Object.keys(langs).join('|');
if (new RegExp(`^/(?!${supported_langs_regex})\\w{2,5}/\\w+`).test(window.location.pathname)) {
if (new RegExp(`^/(?!${supported_langs_regex})\\w{2,5}/\\w+`).test(window.location.pathname.toLowerCase())) {
lang = 'en';
window.location.href = base + '/' + lang + '/' + 'trading.html';
return;
Expand Down

0 comments on commit 2e1ca65

Please sign in to comment.