diff --git a/site/theme/template/Layout/Header.jsx b/site/theme/template/Layout/Header.jsx index 0c26486b8..c52451399 100644 --- a/site/theme/template/Layout/Header.jsx +++ b/site/theme/template/Layout/Header.jsx @@ -84,10 +84,14 @@ export default class Header extends React.Component { handleLangChange = () => { const pathname = this.props.location.pathname; + const currentProtocol = location.protocol + '//'; + const currentHref = location.href.substr(currentProtocol.length); + if (utils.isLocalStorageNameSupported()) { localStorage.setItem('locale', utils.isZhCN(pathname) ? 'en-US' : 'zh-CN'); } - location.href = location.origin + location.pathname.replace( + + location.href = currentProtocol + currentHref.replace( location.pathname, utils.getLocalizedPathname(pathname, !utils.isZhCN(pathname)), );