File tree 1 file changed +29
-1
lines changed
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
376
376
. is_prerelease ( ) ;
377
377
378
378
// If the requested crate version is the most recent, use it to build the url
379
- let latest_path = if is_latest_version {
379
+ let mut latest_path = if is_latest_version {
380
380
format ! ( "/{}/{}" , name, latest_version)
381
381
382
382
// If the requested version is not the latest, then find the path of the latest version for the `Go to latest` link
@@ -394,6 +394,10 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
394
394
} else {
395
395
format ! ( "/crate/{}/{}" , name, latest_version)
396
396
} ;
397
+ if let Some ( query) = req. url . query ( ) {
398
+ latest_path. push ( '?' ) ;
399
+ latest_path. push_str ( query) ;
400
+ }
397
401
398
402
// The path within this crate version's rustdoc output
399
403
let inner_path = {
@@ -1541,4 +1545,28 @@ mod test {
1541
1545
)
1542
1546
} )
1543
1547
}
1548
+
1549
+ #[ test]
1550
+ fn test_latest_version_keeps_query ( ) {
1551
+ wrapper ( |env| {
1552
+ env. fake_release ( )
1553
+ . name ( "tungstenite" )
1554
+ . version ( "0.10.0" )
1555
+ . rustdoc_file ( "tungstenite/index.html" )
1556
+ . create ( ) ?;
1557
+ env. fake_release ( )
1558
+ . name ( "tungstenite" )
1559
+ . version ( "0.11.0" )
1560
+ . rustdoc_file ( "tungstenite/index.html" )
1561
+ . create ( ) ?;
1562
+ assert_eq ! (
1563
+ latest_version_redirect(
1564
+ "/tungstenite/0.10.0/tungstenite/?search=String%20-%3E%20Message" ,
1565
+ env. frontend( )
1566
+ ) ?,
1567
+ "/tungstenite/0.11.0/tungstenite/index.html?search=String%20-%3E%20Message" ,
1568
+ ) ;
1569
+ Ok ( ( ) )
1570
+ } ) ;
1571
+ }
1544
1572
}
You can’t perform that action at this time.
0 commit comments