Skip to content

Commit 86ee1e6

Browse files
committed
Fix redirects if latest version failed to build
Closes rust-lang#502 The redirector behaved differently for `/:crate/:version/:target` than for `/:crate/:version/:target/`. This changes the latest version link to use the former, since it properly accounts for failed builds. Additionally, this changes the `/:target` redirect to keep the query parameter so that `?search=` URLs will be kept.
1 parent aee309f commit 86ee1e6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/web/rustdoc.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
9797
vers: &str,
9898
target_name: &str)
9999
-> IronResult<Response> {
100-
let url = ctry!(Url::parse(&format!("{}/{}/{}/{}/",
100+
let url = ctry!(Url::parse(&format!("{}/{}/{}/{}/?{}",
101101
redirect_base(req),
102102
name,
103103
vers,
104-
target_name)[..]));
104+
target_name,
105+
req.url.query().unwrap_or_default()
106+
)[..]));
105107
let mut resp = Response::with((status::Found, Redirect(url)));
106108
resp.headers.set(Expires(HttpDate(time::now())));
107109

@@ -313,7 +315,7 @@ fn path_for_version(req_path: &[&str], target_name: &str, conn: &Connection) ->
313315
} else {
314316
req_path[3]
315317
};
316-
format!("{}/?search={}", crate_root, search_item)
318+
format!("{}?search={}", crate_root, search_item)
317319
}
318320

319321
pub fn badge_handler(req: &mut Request) -> IronResult<Response> {

0 commit comments

Comments
 (0)