@@ -195,6 +195,7 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
195
195
#[ derive( Debug , Clone , PartialEq , Serialize ) ]
196
196
struct RustdocPage {
197
197
latest_path : String ,
198
+ permalink_path : String ,
198
199
latest_version : String ,
199
200
target : String ,
200
201
inner_path : String ,
@@ -465,11 +466,13 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
465
466
"" . to_string ( )
466
467
} ;
467
468
468
- let latest_path = format ! (
469
+ let permalink_path = format ! (
469
470
"/crate/{}/{}{}{}" ,
470
471
name, latest_version, target_redirect, query_string
471
472
) ;
472
473
474
+ let latest_path = format ! ( "/crate/{}/latest{}{}" , name, target_redirect, query_string) ;
475
+
473
476
metrics
474
477
. recently_accessed_releases
475
478
. record ( krate. crate_id , krate. release_id , target) ;
@@ -483,6 +486,7 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
483
486
rendering_time. step ( "rewrite html" ) ;
484
487
RustdocPage {
485
488
latest_path,
489
+ permalink_path,
486
490
latest_version,
487
491
target,
488
492
inner_path,
@@ -844,25 +848,25 @@ mod test {
844
848
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
845
849
assert_eq ! (
846
850
redirect,
847
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
851
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
848
852
) ;
849
853
850
854
// check it keeps the subpage
851
855
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/blah/" , web) ?;
852
856
assert_eq ! (
853
857
redirect,
854
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/index.html"
858
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/index.html"
855
859
) ;
856
860
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/blah/blah.html" , web) ?;
857
861
assert_eq ! (
858
862
redirect,
859
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/blah.html"
863
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/blah.html"
860
864
) ;
861
865
862
866
// check it also works for deleted pages
863
867
let redirect =
864
868
latest_version_redirect ( "/dummy/0.1.0/dummy/struct.will-be-deleted.html" , web) ?;
865
- assert_eq ! ( redirect, "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/struct.will-be-deleted.html" ) ;
869
+ assert_eq ! ( redirect, "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/struct.will-be-deleted.html" ) ;
866
870
867
871
Ok ( ( ) )
868
872
} )
@@ -892,14 +896,14 @@ mod test {
892
896
latest_version_redirect ( "/dummy/0.1.0/x86_64-pc-windows-msvc/dummy" , web) ?;
893
897
assert_eq ! (
894
898
redirect,
895
- "/crate/dummy/0.2.0 /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
899
+ "/crate/dummy/latest /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
896
900
) ;
897
901
898
902
let redirect =
899
903
latest_version_redirect ( "/dummy/0.1.0/x86_64-pc-windows-msvc/dummy/" , web) ?;
900
904
assert_eq ! (
901
905
redirect,
902
- "/crate/dummy/0.2.0 /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
906
+ "/crate/dummy/latest /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
903
907
) ;
904
908
905
909
let redirect = latest_version_redirect (
@@ -908,7 +912,7 @@ mod test {
908
912
) ?;
909
913
assert_eq ! (
910
914
redirect,
911
- "/crate/dummy/0.2.0 /target-redirect/x86_64-pc-windows-msvc/dummy/struct.Blah.html"
915
+ "/crate/dummy/latest /target-redirect/x86_64-pc-windows-msvc/dummy/struct.Blah.html"
912
916
) ;
913
917
914
918
Ok ( ( ) )
@@ -934,7 +938,7 @@ mod test {
934
938
935
939
let web = env. frontend ( ) ;
936
940
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
937
- assert_eq ! ( redirect, "/crate/dummy/0.2.0 " ) ;
941
+ assert_eq ! ( redirect, "/crate/dummy/latest " ) ;
938
942
939
943
Ok ( ( ) )
940
944
} )
@@ -968,13 +972,13 @@ mod test {
968
972
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
969
973
assert_eq ! (
970
974
redirect,
971
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
975
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
972
976
) ;
973
977
974
978
let redirect = latest_version_redirect ( "/dummy/0.2.1/dummy/" , web) ?;
975
979
assert_eq ! (
976
980
redirect,
977
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
981
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
978
982
) ;
979
983
980
984
Ok ( ( ) )
@@ -1011,13 +1015,13 @@ mod test {
1011
1015
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
1012
1016
assert_eq ! (
1013
1017
redirect,
1014
- "/crate/dummy/0.2.1 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1018
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1015
1019
) ;
1016
1020
1017
1021
let redirect = latest_version_redirect ( "/dummy/0.2.0/dummy/" , web) ?;
1018
1022
assert_eq ! (
1019
1023
redirect,
1020
- "/crate/dummy/0.2.1 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1024
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1021
1025
) ;
1022
1026
1023
1027
Ok ( ( ) )
@@ -1831,14 +1835,14 @@ mod test {
1831
1835
let target_redirect = "/crate/pyo3/0.13.2/target-redirect/x86_64-unknown-linux-gnu/src/pyo3/objects/exc.rs.html" ;
1832
1836
assert_eq ! (
1833
1837
latest_version_redirect(
1834
- "/pyo3/0.2.7 /src/pyo3/objects/exc.rs.html" ,
1838
+ "/pyo3/latest /src/pyo3/objects/exc.rs.html" ,
1835
1839
env. frontend( )
1836
1840
) ?,
1837
1841
target_redirect
1838
1842
) ;
1839
1843
assert_redirect (
1840
1844
target_redirect,
1841
- "/pyo3/0.13.2 /pyo3/?search=exc" ,
1845
+ "/pyo3/latest /pyo3/?search=exc" ,
1842
1846
env. frontend ( ) ,
1843
1847
) ?;
1844
1848
Ok ( ( ) )
0 commit comments