From 5c850256f471d567e22eaae01dbaf565d589e5cd Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 7 Dec 2023 06:55:17 +0800 Subject: [PATCH] feat: empty search `?q=` list all paths (#311) --- src/server.rs | 6 +++++- tests/http.rs | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/server.rs b/src/server.rs index dc76d61..41b7e2e 100644 --- a/src/server.rs +++ b/src/server.rs @@ -497,7 +497,11 @@ impl Server { .get("q") .ok_or_else(|| anyhow!("invalid q"))? .to_lowercase(); - if !search.is_empty() { + if search.is_empty() { + return self + .handle_ls_dir(path, true, query_params, head_only, user, access_paths, res) + .await; + } else { let path_buf = path.to_path_buf(); let hidden = Arc::new(self.args.hidden.to_vec()); let hidden = hidden.clone(); diff --git a/tests/http.rs b/tests/http.rs index 9c0d464..fc6583d 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -147,9 +147,7 @@ fn head_dir_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { #[rstest] fn empty_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { let resp = reqwest::blocking::get(format!("{}?q=", server.url()))?; - assert_eq!(resp.status(), 200); - let paths = utils::retrieve_index_paths(&resp.text()?); - assert!(paths.is_empty()); + assert_resp_paths!(resp); Ok(()) }