@@ -322,18 +322,30 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
322
322
body_class. push_str ( " container-rustdoc" ) ;
323
323
}
324
324
325
+ let latest_release = crate_details. latest_release ( ) ;
326
+
325
327
// 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 ( ) ;
327
329
let is_latest_version = latest_version == version;
328
330
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
+
329
335
// 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 {
331
337
// Replace the version of the old path with the latest version
332
338
let mut latest_path = req_path. clone ( ) ;
333
339
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
+ )
335
347
} else {
336
- String :: new ( )
348
+ format ! ( "/crate/{}/{}" , name , latest_version )
337
349
} ;
338
350
339
351
// The path within this crate version's rustdoc output
@@ -368,7 +380,7 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
368
380
. set_true ( "package_navigation_documentation_tab" )
369
381
. set_true ( "package_navigation_show_platforms_tab" )
370
382
. set_bool ( "is_latest_version" , is_latest_version)
371
- . set ( "latest_path" , & path_in_latest )
383
+ . set ( "latest_path" , & latest_path )
372
384
. set ( "latest_version" , & latest_version)
373
385
. set ( "inner_path" , & inner_path)
374
386
. to_resp ( "rustdoc" )
0 commit comments