Skip to content

Commit 0bc5a05

Browse files
KixironJoshua Nelson
authored andcommitted
Cleaned up from rebase
1 parent 14980a1 commit 0bc5a05

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/web/rustdoc.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,30 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
322322
body_class.push_str(" container-rustdoc");
323323
}
324324

325+
let latest_release = crate_details.latest_release();
326+
325327
// Get the latest version of the crate
326-
let latest_version = crate_details.latest_release().version.to_owned();
328+
let latest_version = latest_release.version.to_owned();
327329
let is_latest_version = latest_version == version;
328330

331+
// If the requested crate version is the most recent, use it to build the url
332+
let latest_path = if is_latest_version {
333+
format!("/{}/{}", name, latest_version)
334+
329335
// If the requested version is not the latest, then find the path of the latest version for the `Go to latest` link
330-
let path_in_latest = if !is_latest_version {
336+
} else if latest_release.build_status {
331337
// Replace the version of the old path with the latest version
332338
let mut latest_path = req_path.clone();
333339
latest_path[2] = &latest_version;
334-
path_for_version(&latest_path, &crate_details.doc_targets, &conn)
340+
341+
format!(
342+
"/{}/{}/{}",
343+
name,
344+
latest_version,
345+
path_for_version(&latest_path, &crate_details.doc_targets, &conn)
346+
)
335347
} else {
336-
String::new()
348+
format!("/crate/{}/{}", name, latest_version)
337349
};
338350

339351
// The path within this crate version's rustdoc output
@@ -368,7 +380,7 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
368380
.set_true("package_navigation_documentation_tab")
369381
.set_true("package_navigation_show_platforms_tab")
370382
.set_bool("is_latest_version", is_latest_version)
371-
.set("latest_path", &path_in_latest)
383+
.set("latest_path", &latest_path)
372384
.set("latest_version", &latest_version)
373385
.set("inner_path", &inner_path)
374386
.to_resp("rustdoc")

0 commit comments

Comments
 (0)