From 5bba3b8c96ece25b757a364f1f32c9a31150df3a Mon Sep 17 00:00:00 2001 From: Christopher Armstrong Date: Tue, 6 Feb 2018 18:11:19 -0600 Subject: [PATCH] Avoid using `Path` to calculate URIs, because it doesn't do the right thing on Windows. --- src/fs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 547a3c415..ca245f007 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -283,12 +283,12 @@ impl Handler for StaticFiles { if path.is_dir() { if let Some(ref redir_index) = self.index { - let mut base = Path::new(req.path()).join(relpath); - base.push(redir_index); + let new_path = format!("{}{}/{}", + req.path(), relpath.to_string_lossy(), redir_index); Ok(FilesystemElement::Redirect( HTTPFound .build() - .header("LOCATION", base.to_string_lossy().as_ref()) + .header::<_, &str>("LOCATION", &new_path) .finish().unwrap())) } else if self.show_index { Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path))) @@ -340,7 +340,7 @@ mod tests { } #[test] - fn test_redirec_to_index() { + fn test_redirect_to_index() { let mut st = StaticFiles::new(".", false).index_file("index.html"); let mut req = HttpRequest::default(); req.match_info_mut().add("tail", "guide");