diff options
| author | Kang Seonghoon <public+git@mearie.org> | 2014-12-04 12:48:16 +0900 |
|---|---|---|
| committer | Kang Seonghoon <public+git@mearie.org> | 2014-12-04 12:48:16 +0900 |
| commit | 4b271f3f64ce334767b8ff10d19abc402a1838b3 (patch) | |
| tree | 0efbaa75e601a6606ff98f8d764189724244fe27 | |
| parent | daa0745886c2382c37d5d345f4c5b1b8f7b9a387 (diff) | |
| download | rust-4b271f3f64ce334767b8ff10d19abc402a1838b3.tar.gz rust-4b271f3f64ce334767b8ff10d19abc402a1838b3.zip | |
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).
| -rw-r--r-- | src/librustdoc/html/layout.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 896d070c155..23f31580619 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -160,6 +160,7 @@ r##"<!DOCTYPE html> } 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 @@ r##"<!DOCTYPE html> <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, |
