Skip to content

Commit 75a6298

Browse files
committed
Serve file directly if it's not html
Closes: #99
1 parent fd78d3e commit 75a6298

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/web/file.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,7 @@ pub struct DatabaseFileHandler;
6868

6969
impl Handler for DatabaseFileHandler {
7070
fn handle(&self, req: &mut Request) -> IronResult<Response> {
71-
72-
let mut path = req.url.path().join("/");
73-
74-
// rustdoc javascript files are kept under rustdoc prefix
75-
// i.e: search-index.js, sidebar-items.js, trait.X.js etc.
76-
// FIXME: This is extremely poor implementation
77-
if path.ends_with(".js") && !path.starts_with("main") && !path.starts_with("jquery") {
78-
path = format!("rustdoc/{}", path);
79-
}
80-
71+
let path = req.url.path().join("/");
8172
let conn = extension!(req, Pool);
8273
if let Some(file) = File::from_path(&conn, &path) {
8374
Ok(file.serve())

src/web/rustdoc.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,16 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
139139
path
140140
};
141141

142-
// don't touch anything other than html files
143-
if !path.ends_with(".html") {
144-
return Err(IronError::new(Nope::ResourceNotFound, status::NotFound));
145-
}
146-
147-
148142
let file = match File::from_path(&conn, &path) {
149143
Some(f) => f,
150144
None => return Err(IronError::new(Nope::ResourceNotFound, status::NotFound)),
151145
};
152146

147+
// serve file directly if it's not html
148+
if !path.ends_with(".html") {
149+
return Ok(file.serve());
150+
}
151+
153152
let (mut in_head, mut in_body) = (false, false);
154153

155154
let mut content = RustdocPage::default();

0 commit comments

Comments
 (0)