提交 f3a85cf8 编写于 作者: C Corey Richardson

rollup merge of #19513: lifthrasiir/rustdoc-fat-redirect

We heavily rely on queries and fragments in the URL structure, so it is desired to preserve them even in the redirects. The generated redirect pages try to preserve them with scripts, which take precedence over the original `Refresh` metadata. Non-scripting browsers would continue to work (with no queries and fragments).

(This in turn solves a number of semi-broken links to the source code, which are actually linked to redirect pages.)
......@@ -160,6 +160,7 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
}
pub fn redirect(dst: &mut io::Writer, url: &str) -> io::IoResult<()> {
// <script> triggers a redirect before refresh, so this is fine.
write!(dst,
r##"<!DOCTYPE html>
<html lang="en">
......@@ -167,6 +168,8 @@ pub fn redirect(dst: &mut io::Writer, url: &str) -> io::IoResult<()> {
<meta http-equiv="refresh" content="0;URL={url}">
</head>
<body>
<p>Redirecting to <a href="{url}">{url}</a>...</p>
<script>location.replace("{url}" + location.search + location.hash);</script>
</body>
</html>"##,
url = url,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册