We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 46fa554 + a24b37a commit a31865eCopy full SHA for a31865e
src/web/mod.rs
@@ -170,21 +170,12 @@ impl CratesfyiHandler {
170
router.get("/:crate/:version/",
171
rustdoc::rustdoc_redirector_handler,
172
"crate_version_");
173
- router.get("/:crate/:version/search-index.js",
174
- rustdoc::rustdoc_html_server_handler,
175
- "crate_version_search_index_js");
176
router.get("/:crate/:version/settings.html",
177
rustdoc::rustdoc_html_server_handler,
178
"crate_version_settings_html");
179
router.get("/:crate/:version/all.html",
180
181
"crate_version_all_html");
182
- router.get("/:crate/:version/aliases.js",
183
184
- "crate_version_aliases_js");
185
- router.get("/:crate/:version/source-files.js",
186
187
- "crate_version_source_files_js");
188
router.get("/:crate/:version/:target",
189
190
"crate_version_target");
src/web/rustdoc.rs
@@ -104,6 +104,15 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
104
Ok(resp)
105
}
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
+
116
let router = extension!(req, Router);
117
// this handler should never called without crate pattern
118
let crate_name = cexpect!(router.find("crate"));
0 commit comments