@@ -285,29 +285,29 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
285
285
///
286
286
/// Returns a path that can be appended to `/crate/version/` to create a complete URL.
287
287
fn path_for_version ( req_path : & [ & str ] , target_name : & str , conn : & Connection ) -> String {
288
+ // Simple case: page exists in the latest version, so just change the version number
288
289
if File :: from_path ( & conn, & req_path. join ( "/" ) ) . is_some ( ) {
289
290
// NOTE: this adds 'index.html' if it wasn't there before
290
- req_path[ 3 ..] . join ( "/" )
291
- } else {
292
- // this page doesn't exist in the latest version
293
- let search_item = if * req_path. last ( ) . unwrap ( ) == "index.html" {
294
- // this is a module
295
- req_path[ req_path. len ( ) - 2 ]
296
- } else {
297
- // this is an item
298
- req_path. last ( ) . unwrap ( ) . split ( '.' ) . nth ( 1 )
299
- . expect ( "paths should be of the form <class>.<name>.html" )
300
- } ;
301
- // check if req_path[3] is the platform choice or the name of the crate
302
- let concat_path;
303
- let crate_root = if req_path[ 3 ] != target_name {
304
- concat_path = format ! ( "{}/{}" , req_path[ 3 ] , req_path[ 4 ] ) ;
305
- & concat_path
306
- } else {
307
- req_path[ 3 ]
308
- } ;
309
- format ! ( "{}/?search={}" , crate_root, search_item)
291
+ return req_path[ 3 ..] . join ( "/" ) ;
310
292
}
293
+ // this page doesn't exist in the latest version
294
+ let search_item = if * req_path. last ( ) . unwrap ( ) == "index.html" {
295
+ // this is a module
296
+ req_path[ req_path. len ( ) - 2 ]
297
+ } else {
298
+ // this is an item
299
+ req_path. last ( ) . unwrap ( ) . split ( '.' ) . nth ( 1 )
300
+ . expect ( "paths should be of the form <class>.<name>.html" )
301
+ } ;
302
+ // check if req_path[3] is the platform choice or the name of the crate
303
+ let concat_path;
304
+ let crate_root = if req_path[ 3 ] != target_name {
305
+ concat_path = format ! ( "{}/{}" , req_path[ 3 ] , req_path[ 4 ] ) ;
306
+ & concat_path
307
+ } else {
308
+ req_path[ 3 ]
309
+ } ;
310
+ format ! ( "{}/?search={}" , crate_root, search_item)
311
311
}
312
312
313
313
pub fn badge_handler ( req : & mut Request ) -> IronResult < Response > {
0 commit comments