From 77158a533ee9035931d1e81b05ef9c64350432e8 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 1 Feb 2021 14:48:56 +0100 Subject: [PATCH] fix: catch edge case of lang in path (#40826) Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> --- client/src/components/createLanguageRedirect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/createLanguageRedirect.js b/client/src/components/createLanguageRedirect.js index 34444c68f8..94c5088063 100644 --- a/client/src/components/createLanguageRedirect.js +++ b/client/src/components/createLanguageRedirect.js @@ -7,12 +7,12 @@ const createLanguageRedirect = ({ clientLocale, lang }) => { .filter(item => (item !== clientLocale && item !== lang ? item : '')) .join('/'); - const domain = window?.location?.host + const hostTail = window?.location?.host .split('.') .slice(1) .join('.'); const nextClient = lang !== 'chinese' ? 'www' : 'chinese'; - const nextLocation = `${window?.location?.protocol}//${nextClient}.${domain}`; + const nextLocation = `${window?.location?.protocol}//${nextClient}.${hostTail}`; if (lang === 'english' || lang === 'chinese') return `${nextLocation}/${path}`;