chore: fix typos and clippy (#379)
This commit is contained in:
parent
d0c79a95e5
commit
75f06f749c
5 changed files with 11 additions and 11 deletions
0
assets/favicon.ico
Executable file → Normal file
0
assets/favicon.ico
Executable file → Normal file
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
|
@ -301,7 +301,7 @@ impl Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(path) = matches.get_one::<PathBuf>("serve-path") {
|
if let Some(path) = matches.get_one::<PathBuf>("serve-path") {
|
||||||
args.serve_path = path.clone()
|
args.serve_path.clone_from(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
args.serve_path = Self::sanitize_path(args.serve_path)?;
|
args.serve_path = Self::sanitize_path(args.serve_path)?;
|
||||||
|
@ -317,7 +317,7 @@ impl Args {
|
||||||
|
|
||||||
args.path_is_file = args.serve_path.metadata()?.is_file();
|
args.path_is_file = args.serve_path.metadata()?.is_file();
|
||||||
if let Some(path_prefix) = matches.get_one::<String>("path-prefix") {
|
if let Some(path_prefix) = matches.get_one::<String>("path-prefix") {
|
||||||
args.path_prefix = path_prefix.clone();
|
args.path_prefix.clone_from(path_prefix)
|
||||||
}
|
}
|
||||||
args.path_prefix = args.path_prefix.trim_matches('/').to_string();
|
args.path_prefix = args.path_prefix.trim_matches('/').to_string();
|
||||||
|
|
||||||
|
|
|
@ -299,14 +299,14 @@ fn auth_data(
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let resp = reqwest::blocking::get(server.url())?;
|
let resp = reqwest::blocking::get(server.url())?;
|
||||||
let content = resp.text()?;
|
let content = resp.text()?;
|
||||||
let json = utils::retrive_json(&content).unwrap();
|
let json = utils::retrieve_json(&content).unwrap();
|
||||||
assert_eq!(json["allow_delete"], serde_json::Value::Bool(false));
|
assert_eq!(json["allow_delete"], serde_json::Value::Bool(false));
|
||||||
assert_eq!(json["allow_upload"], serde_json::Value::Bool(false));
|
assert_eq!(json["allow_upload"], serde_json::Value::Bool(false));
|
||||||
let resp = fetch!(b"GET", server.url())
|
let resp = fetch!(b"GET", server.url())
|
||||||
.basic_auth("user", Some("pass"))
|
.basic_auth("user", Some("pass"))
|
||||||
.send()?;
|
.send()?;
|
||||||
let content = resp.text()?;
|
let content = resp.text()?;
|
||||||
let json = utils::retrive_json(&content).unwrap();
|
let json = utils::retrieve_json(&content).unwrap();
|
||||||
assert_eq!(json["allow_delete"], serde_json::Value::Bool(true));
|
assert_eq!(json["allow_delete"], serde_json::Value::Bool(true));
|
||||||
assert_eq!(json["allow_upload"], serde_json::Value::Bool(true));
|
assert_eq!(json["allow_upload"], serde_json::Value::Bool(true));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -4,7 +4,7 @@ mod utils;
|
||||||
use fixtures::{server, Error, TestServer, BIN_FILE};
|
use fixtures::{server, Error, TestServer, BIN_FILE};
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use utils::retrive_edit_file;
|
use utils::retrieve_edit_file;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn get_dir(server: TestServer) -> Result<(), Error> {
|
fn get_dir(server: TestServer) -> Result<(), Error> {
|
||||||
|
@ -238,7 +238,7 @@ fn get_file_newline_path(server: TestServer) -> Result<(), Error> {
|
||||||
fn get_file_edit(server: TestServer) -> Result<(), Error> {
|
fn get_file_edit(server: TestServer) -> Result<(), Error> {
|
||||||
let resp = fetch!(b"GET", format!("{}index.html?edit", server.url())).send()?;
|
let resp = fetch!(b"GET", format!("{}index.html?edit", server.url())).send()?;
|
||||||
assert_eq!(resp.status(), 200);
|
assert_eq!(resp.status(), 200);
|
||||||
let editable = retrive_edit_file(&resp.text().unwrap()).unwrap();
|
let editable = retrieve_edit_file(&resp.text().unwrap()).unwrap();
|
||||||
assert!(editable);
|
assert!(editable);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ fn get_file_edit(server: TestServer) -> Result<(), Error> {
|
||||||
fn get_file_edit_bin(server: TestServer) -> Result<(), Error> {
|
fn get_file_edit_bin(server: TestServer) -> Result<(), Error> {
|
||||||
let resp = fetch!(b"GET", format!("{}{BIN_FILE}?edit", server.url())).send()?;
|
let resp = fetch!(b"GET", format!("{}{BIN_FILE}?edit", server.url())).send()?;
|
||||||
assert_eq!(resp.status(), 200);
|
assert_eq!(resp.status(), 200);
|
||||||
let editable = retrive_edit_file(&resp.text().unwrap()).unwrap();
|
let editable = retrieve_edit_file(&resp.text().unwrap()).unwrap();
|
||||||
assert!(!editable);
|
assert!(!editable);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ macro_rules! fetch {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn retrieve_index_paths(content: &str) -> IndexSet<String> {
|
pub fn retrieve_index_paths(content: &str) -> IndexSet<String> {
|
||||||
let value = retrive_json(content).unwrap();
|
let value = retrieve_json(content).unwrap();
|
||||||
let paths = value
|
let paths = value
|
||||||
.get("paths")
|
.get("paths")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -47,8 +47,8 @@ pub fn retrieve_index_paths(content: &str) -> IndexSet<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn retrive_edit_file(content: &str) -> Option<bool> {
|
pub fn retrieve_edit_file(content: &str) -> Option<bool> {
|
||||||
let value = retrive_json(content)?;
|
let value = retrieve_json(content)?;
|
||||||
let value = value.get("editable").unwrap();
|
let value = value.get("editable").unwrap();
|
||||||
Some(value.as_bool().unwrap())
|
Some(value.as_bool().unwrap())
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ pub fn encode_uri(v: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn retrive_json(content: &str) -> Option<Value> {
|
pub fn retrieve_json(content: &str) -> Option<Value> {
|
||||||
let lines: Vec<&str> = content.lines().collect();
|
let lines: Vec<&str> = content.lines().collect();
|
||||||
let line = lines.iter().find(|v| v.contains("DATA ="))?;
|
let line = lines.iter().find(|v| v.contains("DATA ="))?;
|
||||||
let line_col = line.find("DATA =").unwrap() + 6;
|
let line_col = line.find("DATA =").unwrap() + 6;
|
||||||
|
|
Loading…
Reference in a new issue