@@ -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 ,
@@ -474,11 +475,13 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
474
475
"" . to_string ( )
475
476
} ;
476
477
477
- let latest_path = format ! (
478
+ let permalink_path = format ! (
478
479
"/crate/{}/{}{}{}" ,
479
480
name, latest_version, target_redirect, query_string
480
481
) ;
481
482
483
+ let latest_path = format ! ( "/crate/{}/latest{}{}" , name, target_redirect, query_string) ;
484
+
482
485
metrics
483
486
. recently_accessed_releases
484
487
. record ( krate. crate_id , krate. release_id , target) ;
@@ -492,6 +495,7 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
492
495
rendering_time. step ( "rewrite html" ) ;
493
496
RustdocPage {
494
497
latest_path,
498
+ permalink_path,
495
499
latest_version,
496
500
target,
497
501
inner_path,
@@ -861,25 +865,25 @@ mod test {
861
865
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
862
866
assert_eq ! (
863
867
redirect,
864
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
868
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
865
869
) ;
866
870
867
871
// check it keeps the subpage
868
872
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/blah/" , web) ?;
869
873
assert_eq ! (
870
874
redirect,
871
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/index.html"
875
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/index.html"
872
876
) ;
873
877
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/blah/blah.html" , web) ?;
874
878
assert_eq ! (
875
879
redirect,
876
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/blah.html"
880
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/blah/blah.html"
877
881
) ;
878
882
879
883
// check it also works for deleted pages
880
884
let redirect =
881
885
latest_version_redirect ( "/dummy/0.1.0/dummy/struct.will-be-deleted.html" , web) ?;
882
- assert_eq ! ( redirect, "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/struct.will-be-deleted.html" ) ;
886
+ assert_eq ! ( redirect, "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/struct.will-be-deleted.html" ) ;
883
887
884
888
Ok ( ( ) )
885
889
} )
@@ -909,14 +913,14 @@ mod test {
909
913
latest_version_redirect ( "/dummy/0.1.0/x86_64-pc-windows-msvc/dummy" , web) ?;
910
914
assert_eq ! (
911
915
redirect,
912
- "/crate/dummy/0.2.0 /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
916
+ "/crate/dummy/latest /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
913
917
) ;
914
918
915
919
let redirect =
916
920
latest_version_redirect ( "/dummy/0.1.0/x86_64-pc-windows-msvc/dummy/" , web) ?;
917
921
assert_eq ! (
918
922
redirect,
919
- "/crate/dummy/0.2.0 /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
923
+ "/crate/dummy/latest /target-redirect/x86_64-pc-windows-msvc/dummy/index.html"
920
924
) ;
921
925
922
926
let redirect = latest_version_redirect (
@@ -925,7 +929,7 @@ mod test {
925
929
) ?;
926
930
assert_eq ! (
927
931
redirect,
928
- "/crate/dummy/0.2.0 /target-redirect/x86_64-pc-windows-msvc/dummy/struct.Blah.html"
932
+ "/crate/dummy/latest /target-redirect/x86_64-pc-windows-msvc/dummy/struct.Blah.html"
929
933
) ;
930
934
931
935
Ok ( ( ) )
@@ -951,7 +955,7 @@ mod test {
951
955
952
956
let web = env. frontend ( ) ;
953
957
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
954
- assert_eq ! ( redirect, "/crate/dummy/0.2.0 " ) ;
958
+ assert_eq ! ( redirect, "/crate/dummy/latest " ) ;
955
959
956
960
Ok ( ( ) )
957
961
} )
@@ -985,13 +989,13 @@ mod test {
985
989
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
986
990
assert_eq ! (
987
991
redirect,
988
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
992
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
989
993
) ;
990
994
991
995
let redirect = latest_version_redirect ( "/dummy/0.2.1/dummy/" , web) ?;
992
996
assert_eq ! (
993
997
redirect,
994
- "/crate/dummy/0.2.0 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
998
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
995
999
) ;
996
1000
997
1001
Ok ( ( ) )
@@ -1028,13 +1032,13 @@ mod test {
1028
1032
let redirect = latest_version_redirect ( "/dummy/0.1.0/dummy/" , web) ?;
1029
1033
assert_eq ! (
1030
1034
redirect,
1031
- "/crate/dummy/0.2.1 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1035
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1032
1036
) ;
1033
1037
1034
1038
let redirect = latest_version_redirect ( "/dummy/0.2.0/dummy/" , web) ?;
1035
1039
assert_eq ! (
1036
1040
redirect,
1037
- "/crate/dummy/0.2.1 /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1041
+ "/crate/dummy/latest /target-redirect/x86_64-unknown-linux-gnu/dummy/index.html"
1038
1042
) ;
1039
1043
1040
1044
Ok ( ( ) )
@@ -1848,14 +1852,14 @@ mod test {
1848
1852
let target_redirect = "/crate/pyo3/0.13.2/target-redirect/x86_64-unknown-linux-gnu/src/pyo3/objects/exc.rs.html" ;
1849
1853
assert_eq ! (
1850
1854
latest_version_redirect(
1851
- "/pyo3/0.2.7 /src/pyo3/objects/exc.rs.html" ,
1855
+ "/pyo3/latest /src/pyo3/objects/exc.rs.html" ,
1852
1856
env. frontend( )
1853
1857
) ?,
1854
1858
target_redirect
1855
1859
) ;
1856
1860
assert_redirect (
1857
1861
target_redirect,
1858
- "/pyo3/0.13.2 /pyo3/?search=exc" ,
1862
+ "/pyo3/latest /pyo3/?search=exc" ,
1859
1863
env. frontend ( ) ,
1860
1864
) ?;
1861
1865
Ok ( ( ) )
0 commit comments