File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -170,9 +170,6 @@ impl CratesfyiHandler {
170
170
router. get ( "/:crate/:version/" ,
171
171
rustdoc:: rustdoc_redirector_handler,
172
172
"crate_version_" ) ;
173
- router. get ( "/:crate/:version/*.js" ,
174
- rustdoc:: rustdoc_redirector_handler,
175
- "crate_version_js" ) ;
176
173
router. get ( "/:crate/:version/settings.html" ,
177
174
rustdoc:: rustdoc_html_server_handler,
178
175
"crate_version_settings_html" ) ;
Original file line number Diff line number Diff line change @@ -104,6 +104,15 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
104
104
Ok ( resp)
105
105
}
106
106
107
+ // this unwrap is safe because iron urls are always able to use `path_segments`
108
+ // i'm using this instead of `req.url.path()` to avoid allocating the Vec, and also to avoid
109
+ // keeping the borrow alive into the return statement
110
+ if req. url . as_ref ( ) . path_segments ( ) . unwrap ( ) . last ( ) . map_or ( false , |s| s. ends_with ( ".js" ) ) {
111
+ // javascript files should be handled by the file server instead of erroneously
112
+ // redirecting to the crate root page
113
+ return rustdoc_html_server_handler ( req) ;
114
+ }
115
+
107
116
let router = extension ! ( req, Router ) ;
108
117
// this handler should never called without crate pattern
109
118
let crate_name = cexpect ! ( router. find( "crate" ) ) ;
You can’t perform that action at this time.
0 commit comments