rustdoc: Preserve query/fragment in redirects whenever possible.
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 commit is contained in:
parent
daa0745886
commit
4b271f3f64
1 changed files with 3 additions and 0 deletions
|
@ -160,6 +160,7 @@ r##"<!DOCTYPE html>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn redirect(dst: &mut io::Writer, url: &str) -> io::IoResult<()> {
|
pub fn redirect(dst: &mut io::Writer, url: &str) -> io::IoResult<()> {
|
||||||
|
// <script> triggers a redirect before refresh, so this is fine.
|
||||||
write!(dst,
|
write!(dst,
|
||||||
r##"<!DOCTYPE html>
|
r##"<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
@ -167,6 +168,8 @@ r##"<!DOCTYPE html>
|
||||||
<meta http-equiv="refresh" content="0;URL={url}">
|
<meta http-equiv="refresh" content="0;URL={url}">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<p>Redirecting to <a href="{url}">{url}</a>...</p>
|
||||||
|
<script>location.replace("{url}" + location.search + location.hash);</script>
|
||||||
</body>
|
</body>
|
||||||
</html>"##,
|
</html>"##,
|
||||||
url = url,
|
url = url,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue