diff --git a/src/server.rs b/src/server.rs index 4620b79..a2d3d2f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -153,7 +153,8 @@ impl Server { } else if query == "zip" { self.handle_zip_dir(path, head_only, &mut res).await?; } else if let Some(q) = query.strip_prefix("q=") { - self.handle_query_dir(path, q, head_only, &mut res).await?; + let q = decode_uri(q).unwrap_or_default(); + self.handle_query_dir(path, &q, head_only, &mut res).await?; } else { self.handle_ls_dir(path, true, head_only, &mut res).await?; } diff --git a/tests/http.rs b/tests/http.rs index 9cf7677..0e5a430 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -74,6 +74,18 @@ fn get_dir_search(server: TestServer) -> Result<(), Error> { Ok(()) } +#[rstest] +fn get_dir_search2(server: TestServer) -> Result<(), Error> { + let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "😀.data"))?; + assert_eq!(resp.status(), 200); + let paths = utils::retrive_index_paths(&resp.text()?); + assert!(!paths.is_empty()); + for p in paths { + assert!(p.contains(&"😀.data")); + } + Ok(()) +} + #[rstest] fn head_dir_search(server: TestServer) -> Result<(), Error> { let resp = fetch!(b"HEAD", format!("{}?q={}", server.url(), "test.html")).send()?;