Skip to content

Commit a645015

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
Fix redirects if latest version failed to build
Closes #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 375dbb2 commit a645015

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/web/rustdoc.rs

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

@@ -342,7 +344,7 @@ fn path_for_version(req_path: &[&str], target_name: &str, conn: &Connection) ->
342344
} else {
343345
req_path[3]
344346
};
345-
format!("{}/?search={}", crate_root, search_item)
347+
format!("{}?search={}", crate_root, search_item)
346348
}
347349

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

0 commit comments

Comments
 (0)