File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -521,8 +521,9 @@ fn path_for_version(
521
521
// this is an item
522
522
last_component. split ( '.' ) . nth ( 1 )
523
523
} else {
524
- // this is a source file; try searching for the module
525
- Some ( last_component. strip_suffix ( ".rs.html" ) . unwrap ( ) )
524
+ // if this is a Rust source file, try searching for the module;
525
+ // else, don't try searching at all, we don't know how to find it
526
+ last_component. strip_suffix ( ".rs.html" )
526
527
} ;
527
528
if let Some ( search) = search_item {
528
529
format ! ( "{}?search={}" , platform, search)
@@ -1810,4 +1811,29 @@ mod test {
1810
1811
Ok ( ( ) )
1811
1812
} )
1812
1813
}
1814
+
1815
+ #[ test]
1816
+ fn test_redirect_source_not_rust ( ) {
1817
+ wrapper ( |env| {
1818
+ env. fake_release ( )
1819
+ . name ( "winapi" )
1820
+ . version ( "0.3.8" )
1821
+ . source_file ( "src/docs.md" , b"created by Peter Rabbit" )
1822
+ . create ( ) ?;
1823
+
1824
+ env. fake_release ( )
1825
+ . name ( "winapi" )
1826
+ . version ( "0.3.9" )
1827
+ . create ( ) ?;
1828
+
1829
+ assert_success ( "/winapi/0.3.8/src/winapi/docs.md.html" , env. frontend ( ) ) ?;
1830
+ // people can end up here from clicking "go to latest" while in source view
1831
+ assert_redirect (
1832
+ "/crate/winapi/0.3.9/target-redirect/src/winapi/docs.md.html" ,
1833
+ "/winapi/0.3.9/winapi/" ,
1834
+ env. frontend ( ) ,
1835
+ ) ?;
1836
+ Ok ( ( ) )
1837
+ } )
1838
+ }
1813
1839
}
You can’t perform that action at this time.
0 commit comments