fix: catch edge case of lang in path (#40826)

Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com>
This commit is contained in:
Oliver Eyton-Williams
2021-02-01 14:48:56 +01:00
committed by GitHub
parent 22f017caa2
commit 77158a533e

View File

@ -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}`;