@@ -238,7 +238,7 @@ 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 = {
241
+ let mut path = {
242
242
let mut path = req_path. join ( "/" ) ;
243
243
if path. ends_with ( '/' ) {
244
244
req_path. pop ( ) ; // get rid of empty string
@@ -250,7 +250,15 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
250
250
251
251
let file = match File :: from_path ( & conn, & path) {
252
252
Some ( f) => f,
253
- None => return Err ( IronError :: new ( Nope :: ResourceNotFound , status:: NotFound ) ) ,
253
+ None => {
254
+ //If it fails, we try again with /index.html at the end
255
+ path. push_str ( "/index.html" ) ;
256
+ req_path. push ( "index.html" ) ;
257
+ match File :: from_path ( & conn, & path) {
258
+ Some ( f) => f,
259
+ None => return Err ( IronError :: new ( Nope :: ResourceNotFound , status:: NotFound ) ) ,
260
+ }
261
+ } ,
254
262
} ;
255
263
256
264
// serve file directly if it's not html
@@ -439,7 +447,11 @@ mod test {
439
447
. name ( "buggy" ) . version ( "0.1.0" )
440
448
. build_result_successful ( true )
441
449
. rustdoc_file ( "settings.html" , b"some data" )
450
+ . rustdoc_file ( "directoty_1/index.html" , b"some data 1" )
451
+ . rustdoc_file ( "directoty_2.html/index.html" , b"some data 1" )
442
452
. rustdoc_file ( "all.html" , b"some data 2" )
453
+ . rustdoc_file ( "directory_3/.gitignore" , b"*.ext" )
454
+ . rustdoc_file ( "directory_4/empty_file_no_ext" , b"" )
443
455
. create ( ) ?;
444
456
db. fake_release ( )
445
457
. name ( "buggy" ) . version ( "0.2.0" )
@@ -448,8 +460,12 @@ mod test {
448
460
let web = env. frontend ( ) ;
449
461
assert_success ( "/" , web) ?;
450
462
assert_success ( "/crate/buggy/0.1.0/" , web) ?;
463
+ assert_success ( "/buggy/0.1.0/directoty_1/index.html" , web) ?;
464
+ assert_success ( "/buggy/0.1.0/directoty_2.html/index.html" , web) ?;
465
+ assert_success ( "/buggy/0.1.0/directory_3/.gitignore" , web) ?;
451
466
assert_success ( "/buggy/0.1.0/settings.html" , web) ?;
452
467
assert_success ( "/buggy/0.1.0/all.html" , web) ?;
468
+ assert_success ( "/buggy/0.1.0/directory_4/empty_file_no_ext" , web) ?;
453
469
Ok ( ( ) )
454
470
} ) ;
455
471
}
@@ -488,7 +504,9 @@ mod test {
488
504
assert_success ( base, web) ?;
489
505
assert_redirect ( "/dummy/0.3.0/x86_64-unknown-linux-gnu/dummy/" , base, web) ?;
490
506
assert_redirect ( "/dummy/0.3.0/x86_64-unknown-linux-gnu/all.html" , "/dummy/0.3.0/all.html" , web) ?;
491
- assert_redirect ( "/dummy/0.3.0/" , base, web)
507
+ assert_redirect ( "/dummy/0.3.0/" , base, web) ?;
508
+ assert_redirect ( "/dummy/0.3.0/index.html" , base, web) ?;
509
+ Ok ( ( ) )
492
510
} ) ;
493
511
}
494
512
}
0 commit comments