@@ -305,8 +305,11 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
305
305
path. push_str ( "/index.html" ) ;
306
306
req_path. push ( "index.html" ) ;
307
307
308
- File :: from_path ( & storage, & path, & config)
309
- . map_err ( |_| IronError :: new ( Nope :: ResourceNotFound , status:: NotFound ) ) ?
308
+ return if ctry ! ( req, storage. exists( & path) ) {
309
+ redirect ( & name, & version, & req_path[ 3 ..] )
310
+ } else {
311
+ Err ( IronError :: new ( Nope :: ResourceNotFound , status:: NotFound ) )
312
+ } ;
310
313
} ;
311
314
312
315
// Serve non-html files directly
@@ -1387,7 +1390,7 @@ mod test {
1387
1390
1388
1391
#[ test]
1389
1392
// regression test for https://github.com/rust-lang/docs.rs/issues/856
1390
- fn test_no_trailing_slash ( ) {
1393
+ fn test_no_trailing_target_slash ( ) {
1391
1394
wrapper ( |env| {
1392
1395
env. fake_release ( ) . name ( "dummy" ) . version ( "0.1.0" ) . create ( ) ?;
1393
1396
let web = env. frontend ( ) ;
@@ -1493,4 +1496,20 @@ mod test {
1493
1496
Ok ( ( ) )
1494
1497
} )
1495
1498
}
1499
+
1500
+ #[ test]
1501
+ fn test_no_trailing_rustdoc_slash ( ) {
1502
+ wrapper ( |env| {
1503
+ env. fake_release ( )
1504
+ . name ( "tokio" )
1505
+ . version ( "0.2.21" )
1506
+ . rustdoc_file ( "tokio/time/index.html" , b"content" )
1507
+ . create ( ) ?;
1508
+ assert_redirect (
1509
+ "/tokio/0.2.21/tokio/time" ,
1510
+ "/tokio/0.2.21/tokio/time/index.html" ,
1511
+ env. frontend ( ) ,
1512
+ )
1513
+ } )
1514
+ }
1496
1515
}
0 commit comments