@@ -238,15 +238,18 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
238
238
return Ok ( super :: redirect ( canonical) ) ;
239
239
}
240
240
241
- let path = {
242
- let mut path = req_path. join ( "/" ) ;
243
- if path. ends_with ( '/' ) {
241
+ if let Some ( & end) = req_path. last ( ) {
242
+ if end == "" {
244
243
req_path. pop ( ) ; // get rid of empty string
245
- path. push_str ( "index.html" ) ;
246
244
req_path. push ( "index.html" ) ;
245
+ } else if !end. contains ( '.' ) {
246
+ req_path. push ( "index.html" ) ;
247
+ } else {
248
+ // page might already have extension, so do nothing
247
249
}
248
- path
249
- } ;
250
+ }
251
+
252
+ let path = req_path. join ( "/" ) ;
250
253
251
254
let file = match File :: from_path ( & conn, & path) {
252
255
Some ( f) => f,
@@ -440,6 +443,7 @@ mod test {
440
443
. build_result_successful ( true )
441
444
. rustdoc_file ( "settings.html" , b"some data" )
442
445
. rustdoc_file ( "all.html" , b"some data 2" )
446
+ . rustdoc_file ( "some_module/other_module/index.html" , b"some data 2" )
443
447
. create ( ) ?;
444
448
db. fake_release ( )
445
449
. name ( "buggy" ) . version ( "0.2.0" )
@@ -448,8 +452,10 @@ mod test {
448
452
let web = env. frontend ( ) ;
449
453
assert_success ( "/" , web) ?;
450
454
assert_success ( "/crate/buggy/0.1.0/" , web) ?;
455
+ assert_success ( "/crate/buggy/0.1.0/" , web) ?;
451
456
assert_success ( "/buggy/0.1.0/settings.html" , web) ?;
452
457
assert_success ( "/buggy/0.1.0/all.html" , web) ?;
458
+ assert_success ( "/buggy/0.1.0/some_module/other_module" , web) ?;
453
459
Ok ( ( ) )
454
460
} ) ;
455
461
}
@@ -484,6 +490,7 @@ mod test {
484
490
. rustdoc_file ( "dummy/index.html" , b"some content" )
485
491
. rustdoc_file ( "all.html" , b"html" )
486
492
. default_target ( target) . create ( ) ?;
493
+
487
494
let base = "/dummy/0.3.0/dummy/" ;
488
495
assert_success ( base, web) ?;
489
496
assert_redirect ( "/dummy/0.3.0/x86_64-unknown-linux-gnu/dummy/" , base, web) ?;
0 commit comments