Fix clippy lints

This commit is contained in:
Matthias 2021-09-03 23:21:24 +02:00
parent 57af648ec9
commit b3c5d122e7
4 changed files with 8 additions and 9 deletions

View file

@ -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<String> {
.collect()
}
fn create_uri_from_path(root: &PathBuf, base: &Option<Base>, link: &str) -> Result<Url> {
let link = url::remove_get_params(&link);
fn create_uri_from_path(root: &Path, base: &Option<Base>, link: &str) -> Result<Url> {
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)]

View file

@ -39,7 +39,7 @@ pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option<Base>) -> Result<Pat
// Find `dst` in the parent directory of `src`
if let Some(parent) = src.parent() {
let rel_path = parent.join(dst.to_path_buf());
return Ok(absolute_path(&rel_path)?);
return absolute_path(&rel_path);
}
}
if dst.is_absolute() {
@ -49,11 +49,10 @@ pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option<Base>) -> Result<Pat
ErrorKind::InvalidBase(
"<empty>".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()))
}

View file

@ -40,7 +40,7 @@ impl TryFrom<&str> for Base {
type Error = ErrorKind;
fn try_from(value: &str) -> Result<Self, Self::Error> {
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(),

View file

@ -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