From cc0014c183831674f3318794a6f9d1c137e32ee4 Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 3 Aug 2022 08:51:12 +0800 Subject: [PATCH] chore: fix typo --- assets/index.js | 10 +++++----- src/auth.rs | 6 +++--- src/main.rs | 6 +++--- tests/allow.rs | 2 +- tests/fixtures.rs | 4 ++-- tests/hidden.rs | 4 ++-- tests/http.rs | 4 ++-- tests/render.rs | 2 +- tests/symlink.rs | 4 ++-- tests/utils.rs | 8 ++++---- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/assets/index.js b/assets/index.js index 3a87e11..df1e2b7 100644 --- a/assets/index.js +++ b/assets/index.js @@ -75,7 +75,7 @@ class Uploader { } ajax() { - Uploader.runings += 1; + Uploader.runnings += 1; const url = getUrl(this.name); this.lastUptime = Date.now(); const ajax = new XMLHttpRequest(); @@ -110,20 +110,20 @@ class Uploader { complete() { this.$uploadStatus.innerHTML = `✓`; - Uploader.runings -= 1; + Uploader.runnings -= 1; Uploader.runQueue(); } fail() { this.$uploadStatus.innerHTML = `✗`; - Uploader.runings -= 1; + Uploader.runnings -= 1; Uploader.runQueue(); } } Uploader.globalIdx = 0; -Uploader.runings = 0; +Uploader.runnings = 0; /** * @type Uploader[] @@ -132,7 +132,7 @@ Uploader.queues = []; Uploader.runQueue = () => { - if (Uploader.runings > 2) return; + if (Uploader.runnings > 2) return; let uploader = Uploader.queues.shift(); if (!uploader) return; uploader.ajax(); diff --git a/src/auth.rs b/src/auth.rs index 5d10b40..065fd04 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -357,12 +357,12 @@ fn strip_prefix<'a>(search: &'a [u8], prefix: &[u8]) -> Option<&'a [u8]> { fn to_headermap(header: &[u8]) -> Result, ()> { let mut sep = Vec::new(); - let mut asign = Vec::new(); + let mut assign = Vec::new(); let mut i: usize = 0; let mut esc = false; for c in header { match (c, esc) { - (b'=', false) => asign.push(i), + (b'=', false) => assign.push(i), (b',', false) => sep.push(i), (b'"', false) => esc = true, (b'"', true) => esc = false, @@ -374,7 +374,7 @@ fn to_headermap(header: &[u8]) -> Result, ()> { i = 0; let mut ret = HashMap::new(); - for (&k, &a) in sep.iter().zip(asign.iter()) { + for (&k, &a) in sep.iter().zip(assign.iter()) { while header[i] == b' ' { i += 1; } diff --git a/src/main.rs b/src/main.rs index 9068a35..ed85e8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ fn serve( let inner = inner.clone(); let incoming = create_addr_incoming(SocketAddr::new(*ip, port)) .map_err(|e| format!("Failed to bind `{}:{}`, {}", ip, port, e))?; - let serv_func = move |remote_addr: SocketAddr| { + let serve_func = move |remote_addr: SocketAddr| { let inner = inner.clone(); async move { Ok::<_, hyper::Error>(service_fn(move |req: Request| { @@ -99,7 +99,7 @@ fn serve( let accepter = TlsAcceptor::new(config.clone(), incoming); let new_service = make_service_fn(move |socket: &TlsStream| { let remote_addr = socket.remote_addr(); - serv_func(remote_addr) + serve_func(remote_addr) }); let server = tokio::spawn(hyper::Server::builder(accepter).serve(new_service)); handles.push(server); @@ -111,7 +111,7 @@ fn serve( None => { let new_service = make_service_fn(move |socket: &AddrStream| { let remote_addr = socket.remote_addr(); - serv_func(remote_addr) + serve_func(remote_addr) }); let server = tokio::spawn(hyper::Server::builder(incoming).serve(new_service)); handles.push(server); diff --git a/tests/allow.rs b/tests/allow.rs index f83a891..10631b9 100644 --- a/tests/allow.rs +++ b/tests/allow.rs @@ -64,7 +64,7 @@ fn allow_upload_delete_can_override(#[with(&["-A"])] server: TestServer) -> Resu fn allow_search(#[with(&["--allow-search"])] server: TestServer) -> Result<(), Error> { let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?; assert_eq!(resp.status(), 200); - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert!(!paths.is_empty()); for p in paths { assert!(p.contains("test.html")); diff --git a/tests/fixtures.rs b/tests/fixtures.rs index f53457f..669a1ae 100644 --- a/tests/fixtures.rs +++ b/tests/fixtures.rs @@ -15,11 +15,11 @@ pub type Error = Box; #[allow(dead_code)] pub static FILES: &[&str] = &["test.txt", "test.html", "index.html", "😀.bin"]; -/// Directory names for testing diretory don't exist +/// Directory names for testing directory don't exist #[allow(dead_code)] pub static DIR_NO_FOUND: &str = "dir-no-found/"; -/// Directory names for testing diretory don't have index.html +/// Directory names for testing directory don't have index.html #[allow(dead_code)] pub static DIR_NO_INDEX: &str = "dir-no-index/"; diff --git a/tests/hidden.rs b/tests/hidden.rs index 1f4f91f..e9205d0 100644 --- a/tests/hidden.rs +++ b/tests/hidden.rs @@ -10,7 +10,7 @@ use rstest::rstest; fn hidden_get_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> { let resp = reqwest::blocking::get(server.url())?; assert_eq!(resp.status(), 200); - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert_eq!(paths.contains(".git/"), exist); assert_eq!(paths.contains("index.html"), exist); Ok(()) @@ -34,7 +34,7 @@ fn hidden_propfind_dir(#[case] server: TestServer, #[case] exist: bool) -> Resul fn hidden_search_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> { let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?; assert_eq!(resp.status(), 200); - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); for p in paths { assert_eq!(p.contains("test.html"), exist); } diff --git a/tests/http.rs b/tests/http.rs index bb52356..1c95c67 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -66,7 +66,7 @@ fn head_dir_zip(server: TestServer) -> Result<(), Error> { fn get_dir_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?; assert_eq!(resp.status(), 200); - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert!(!paths.is_empty()); for p in paths { assert!(p.contains("test.html")); @@ -78,7 +78,7 @@ fn get_dir_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { fn get_dir_search2(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "😀.bin"))?; assert_eq!(resp.status(), 200); - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert!(!paths.is_empty()); for p in paths { assert!(p.contains("😀.bin")); diff --git a/tests/render.rs b/tests/render.rs index 29644c6..6f0b60b 100644 --- a/tests/render.rs +++ b/tests/render.rs @@ -56,7 +56,7 @@ fn render_try_index3(#[with(&["--render-try-index"])] server: TestServer) -> Res fn render_try_index4(#[case] server: TestServer, #[case] searched: bool) -> Result<(), Error> { let resp = reqwest::blocking::get(format!("{}{}?q={}", server.url(), DIR_NO_INDEX, "😀.bin"))?; assert_eq!(resp.status(), 200); - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert!(!paths.is_empty()); assert_eq!(paths.iter().all(|v| v.contains("😀.bin")), searched); Ok(()) diff --git a/tests/symlink.rs b/tests/symlink.rs index 85a7261..7eeeadd 100644 --- a/tests/symlink.rs +++ b/tests/symlink.rs @@ -20,7 +20,7 @@ fn default_not_allow_symlink(server: TestServer, tmpdir: TempDir) -> Result<(), let resp = reqwest::blocking::get(format!("{}{}/index.html", server.url(), dir))?; assert_eq!(resp.status(), 404); let resp = reqwest::blocking::get(server.url())?; - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert!(!paths.is_empty()); assert!(!paths.contains(&format!("{}/", dir))); Ok(()) @@ -39,7 +39,7 @@ fn allow_symlink( let resp = reqwest::blocking::get(format!("{}{}/index.html", server.url(), dir))?; assert_eq!(resp.status(), 200); let resp = reqwest::blocking::get(server.url())?; - let paths = utils::retrive_index_paths(&resp.text()?); + let paths = utils::retrieve_index_paths(&resp.text()?); assert!(!paths.is_empty()); assert!(paths.contains(&format!("{}/", dir))); Ok(()) diff --git a/tests/utils.rs b/tests/utils.rs index a0cff6e..5b01cbe 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -9,7 +9,7 @@ macro_rules! assert_resp_paths { ($resp:ident, $files:expr) => { assert_eq!($resp.status(), 200); let body = $resp.text()?; - let paths = self::utils::retrive_index_paths(&body); + let paths = self::utils::retrieve_index_paths(&body); assert!(!paths.is_empty()); for file in $files { assert!(paths.contains(&file.to_string())); @@ -25,8 +25,8 @@ macro_rules! fetch { } #[allow(dead_code)] -pub fn retrive_index_paths(index: &str) -> HashSet { - retrive_index_paths_impl(index).unwrap_or_default() +pub fn retrieve_index_paths(index: &str) -> HashSet { + retrieve_index_paths_impl(index).unwrap_or_default() } #[allow(dead_code)] @@ -35,7 +35,7 @@ pub fn encode_uri(v: &str) -> String { parts.join("/") } -fn retrive_index_paths_impl(index: &str) -> Option> { +fn retrieve_index_paths_impl(index: &str) -> Option> { let lines: Vec<&str> = index.lines().collect(); let line = lines.iter().find(|v| v.contains("DATA ="))?; let value: Value = line[7..].parse().ok()?;