mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-18 10:41:06 +00:00
Fix clippy lints
This commit is contained in:
parent
57af648ec9
commit
b3c5d122e7
4 changed files with 8 additions and 9 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue