Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antD首页从英文切换到中文时,replace导致链接错误 #5050

Merged
merged 1 commit into from
Feb 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/theme/template/Layout/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class Header extends React.Component {
if (utils.isLocalStorageNameSupported()) {
localStorage.setItem('locale', utils.isZhCN(pathname) ? 'en-US' : 'zh-CN');
}
location.href = location.href.replace(
location.href = location.origin + location.pathname.replace(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样 hash 和 queryString 就丢失了。。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjycui 嗯,我想到另外一个方案,先把href的protocol(http://)字段截取,replace后再补回来,这次我在本地带hash和query测过,可用。我再发一个PR :)

location.pathname,
utils.getLocalizedPathname(pathname, !utils.isZhCN(pathname)),
);
Expand Down