File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,18 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
111
111
if req. url . as_ref ( ) . path_segments ( ) . unwrap ( ) . last ( ) . map_or ( false , |s| s. ends_with ( ".js" ) ) {
112
112
// javascript files should be handled by the file server instead of erroneously
113
113
// redirecting to the crate root page
114
- return rustdoc_html_server_handler ( req) ;
114
+ if req. url . as_ref ( ) . path_segments ( ) . unwrap ( ) . count ( ) > 2 {
115
+ // this URL is actually from a crate-internal path, serve it there instead
116
+ return rustdoc_html_server_handler ( req) ;
117
+ } else {
118
+ let path = req. url . path ( ) ;
119
+ let path = path. join ( "/" ) ;
120
+ let conn = extension ! ( req, Pool ) ;
121
+ match File :: from_path ( & conn, & path) {
122
+ Some ( f) => return Ok ( f. serve ( ) ) ,
123
+ None => return Err ( IronError :: new ( Nope :: ResourceNotFound , status:: NotFound ) ) ,
124
+ }
125
+ }
115
126
} else if req. url . as_ref ( ) . path_segments ( ) . unwrap ( ) . last ( ) . map_or ( false , |s| s. ends_with ( ".ico" ) ) {
116
127
// route .ico files into their dedicated handler so that docs.rs's favicon is always
117
128
// displayed
You can’t perform that action at this time.
0 commit comments