feat: empty search ?q= list all paths (#311)

This commit is contained in:
sigoden 2023-12-07 06:55:17 +08:00 committed by GitHub
parent 0cec573579
commit 5c850256f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -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();

View file

@ -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(())
}