From 527d7ece2b346d657259bc2562c07ae02a258ad7 Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Fri, 14 Jun 2024 12:24:41 +0400 Subject: [PATCH] chore: redirection fix for mn and km --- themes/gatsby-theme-deriv/gatsby-browser.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/themes/gatsby-theme-deriv/gatsby-browser.js b/themes/gatsby-theme-deriv/gatsby-browser.js index 1129510fd23..98cf5624e8d 100644 --- a/themes/gatsby-theme-deriv/gatsby-browser.js +++ b/themes/gatsby-theme-deriv/gatsby-browser.js @@ -162,6 +162,22 @@ export const onRouteUpdate = ({ location }) => { const client_information = getClientInformation(domain) const is_logged_in = !!client_information + const path = location.pathname; + + if (path === '/mn') { + navigate('/', { replace: true }); + } else if (path.startsWith('/mn/')) { + const newPath = path.replace(/^\/mn/, ''); + navigate(newPath || '/', { replace: true }); + } + + if (path === '/km') { + navigate('/', { replace: true }); + } else if (path.startsWith('/km/')) { + const newPath = path.replace(/^\/km/, ''); + navigate(newPath || '/', { replace: true }); + } + // wrap inside a timeout to ensure the title has properly been changed setTimeout(() => { const eventName = 'page_load'