diff --git a/lychee-lib/src/extract.rs b/lychee-lib/src/extract.rs index 41b62e3..0a48b33 100644 --- a/lychee-lib/src/extract.rs +++ b/lychee-lib/src/extract.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, convert::TryFrom, path::PathBuf}; +use std::{collections::HashSet, convert::TryFrom, path::Path, path::PathBuf}; use html5ever::{ parse_document, @@ -122,10 +122,10 @@ fn extract_links_from_plaintext(input: &str) -> Vec { .collect() } -fn create_uri_from_path(root: &PathBuf, base: &Option, link: &str) -> Result { - let link = url::remove_get_params(&link); +fn create_uri_from_path(root: &Path, base: &Option, link: &str) -> Result { + let link = url::remove_get_params(link); let path = path::resolve(root, &PathBuf::from(&link), base)?; - Ok(Url::from_file_path(&path).map_err(|_e| ErrorKind::InvalidPath(path))?) + Url::from_file_path(&path).map_err(|_e| ErrorKind::InvalidPath(path)) } #[cfg(test)] diff --git a/lychee-lib/src/helpers/path.rs b/lychee-lib/src/helpers/path.rs index fda4660..87445c3 100644 --- a/lychee-lib/src/helpers/path.rs +++ b/lychee-lib/src/helpers/path.rs @@ -39,7 +39,7 @@ pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option) -> Result) -> Result".to_string(), format!("Found absolute local link {:?} but no base directory was set. Set with `--base`.", dst) - .to_string(), ) })?; let abs_path = join(dirname(&base), dst); - return Ok(absolute_path(&abs_path)?); + return absolute_path(&abs_path); } Err(ErrorKind::FileNotFound(dst.to_path_buf())) } diff --git a/lychee-lib/src/types/base.rs b/lychee-lib/src/types/base.rs index f38ec29..affeacc 100644 --- a/lychee-lib/src/types/base.rs +++ b/lychee-lib/src/types/base.rs @@ -40,7 +40,7 @@ impl TryFrom<&str> for Base { type Error = ErrorKind; fn try_from(value: &str) -> Result { - if let Ok(url) = Url::parse(&value) { + if let Ok(url) = Url::parse(value) { if url.cannot_be_a_base() { return Err(ErrorKind::InvalidBase( value.to_string(), diff --git a/lychee-lib/src/types/input.rs b/lychee-lib/src/types/input.rs index 20a9f2f..ad5ed83 100644 --- a/lychee-lib/src/types/input.rs +++ b/lychee-lib/src/types/input.rs @@ -83,7 +83,7 @@ impl Input { pub fn new(value: &str, glob_ignore_case: bool) -> Self { if value == STDIN { Self::Stdin - } else if let Ok(url) = Url::parse(&value) { + } else if let Ok(url) = Url::parse(value) { Self::RemoteUrl(Box::new(url)) } else { // this seems to be the only way to determine if this is a glob pattern