Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust 1.83.0 #1581

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lychee-bin/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async fn progress_bar_task(
while let Some(response) = recv_resp.recv().await {
show_progress(
&mut io::stderr(),
&pb,
pb.as_ref(),
&response,
formatter.as_ref(),
&verbose,
Expand Down Expand Up @@ -331,7 +331,7 @@ fn ignore_cache(uri: &Uri, status: &Status, cache_exclude_status: &HashSet<u16>)

fn show_progress(
output: &mut dyn Write,
progress_bar: &Option<ProgressBar>,
progress_bar: Option<&ProgressBar>,
response: &Response,
formatter: &dyn ResponseFormatter,
verbose: &Verbosity,
Expand Down Expand Up @@ -401,7 +401,7 @@ mod tests {
let formatter = get_response_formatter(&options::OutputMode::Plain);
show_progress(
&mut buf,
&None,
None,
&response,
formatter.as_ref(),
&Verbosity::default(),
Expand All @@ -423,7 +423,7 @@ mod tests {
let formatter = get_response_formatter(&options::OutputMode::Plain);
show_progress(
&mut buf,
&None,
None,
&response,
formatter.as_ref(),
&Verbosity::debug(),
Expand Down
11 changes: 8 additions & 3 deletions lychee-lib/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ impl Collector {
let content = content?;
let extractor = Extractor::new(self.use_html5ever, self.include_verbatim);
let uris: Vec<RawUri> = extractor.extract(&content);
let requests = request::create(uris, &content, &base, &basic_auth_extractor);
let requests = request::create(
uris,
&content,
base.as_ref(),
basic_auth_extractor.as_ref(),
);
Result::Ok(stream::iter(requests.into_iter().map(Ok)))
}
})
Expand Down Expand Up @@ -493,8 +498,8 @@ mod tests {
source: InputSource::String(
r#"
<a href="index.html">Index</a>
<a href="about.html">About</a>
<a href="/another.html">Another</a>
<a href="about.html">About</a>
<a href="/another.html">Another</a>
"#
.into(),
),
Expand Down
1 change: 1 addition & 0 deletions lychee-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub mod filter;

#[cfg(test)]
#[macro_use]
/// Utility functions and macros to help testing lychee
pub mod test_utils;

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion lychee-lib/src/types/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ impl<P: AsRef<Path>> From<P> for FileType {
}

/// Helper function to check if a path is likely a URL.

fn is_url(path: &Path) -> bool {
path.to_str()
.and_then(|s| Url::parse(s).ok())
Expand Down
20 changes: 10 additions & 10 deletions lychee-lib/src/utils/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ static CURRENT_DIR: Lazy<PathBuf> =
Lazy::new(|| env::current_dir().expect("cannot get current dir from environment"));

/// Returns the base if it is a valid `PathBuf`
fn get_base_dir(base: &Option<Base>) -> Option<PathBuf> {
base.as_ref().and_then(Base::dir)
fn get_base_dir(base: Option<&Base>) -> Option<PathBuf> {
base.and_then(Base::dir)
}

/// Create an absolute path out of a `PathBuf`.
Expand Down Expand Up @@ -40,7 +40,7 @@ fn dirname(src: &'_ Path) -> Option<&'_ Path> {
/// Resolve `dst` that was linked to from within `src`
///
/// Returns Ok(None) in case of an absolute local link without a `base_url`
pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option<Base>) -> Result<Option<PathBuf>> {
pub(crate) fn resolve(src: &Path, dst: &Path, base: Option<&Base>) -> Result<Option<PathBuf>> {
let resolved = match dst {
relative if dst.is_relative() => {
// Find `dst` in the parent directory of `src`
Expand Down Expand Up @@ -110,7 +110,7 @@ mod test_path {
let dummy = PathBuf::from("index.html");
let abs_path = PathBuf::from("./foo.html");
assert_eq!(
resolve(&dummy, &abs_path, &None)?,
resolve(&dummy, &abs_path, None)?,
Some(env::current_dir().unwrap().join("foo.html"))
);
Ok(())
Expand All @@ -123,7 +123,7 @@ mod test_path {
let dummy = PathBuf::from("./index.html");
let abs_path = PathBuf::from("./foo.html");
assert_eq!(
resolve(&dummy, &abs_path, &None)?,
resolve(&dummy, &abs_path, None)?,
Some(env::current_dir().unwrap().join("foo.html"))
);
Ok(())
Expand All @@ -136,7 +136,7 @@ mod test_path {
let abs_index = PathBuf::from("/path/to/index.html");
let abs_path = PathBuf::from("./foo.html");
assert_eq!(
resolve(&abs_index, &abs_path, &None)?,
resolve(&abs_index, &abs_path, None)?,
Some(PathBuf::from("/path/to/foo.html"))
);
Ok(())
Expand All @@ -149,9 +149,9 @@ mod test_path {
fn test_resolve_absolute_from_base_dir() -> Result<()> {
let dummy = PathBuf::new();
let abs_path = PathBuf::from("/foo.html");
let base = Some(Base::Local(PathBuf::from("/some/absolute/base/dir")));
let base = Base::Local(PathBuf::from("/some/absolute/base/dir"));
assert_eq!(
resolve(&dummy, &abs_path, &base)?,
resolve(&dummy, &abs_path, Some(&base))?,
Some(PathBuf::from("/some/absolute/base/dir/foo.html"))
);
Ok(())
Expand All @@ -163,9 +163,9 @@ mod test_path {
fn test_resolve_absolute_from_absolute() -> Result<()> {
let abs_index = PathBuf::from("/path/to/index.html");
let abs_path = PathBuf::from("/other/path/to/foo.html");
let base = Some(Base::Local(PathBuf::from("/some/absolute/base/dir")));
let base = Base::Local(PathBuf::from("/some/absolute/base/dir"));
assert_eq!(
resolve(&abs_index, &abs_path, &base)?,
resolve(&abs_index, &abs_path, Some(&base))?,
Some(PathBuf::from(
"/some/absolute/base/dir/other/path/to/foo.html"
))
Expand Down
Loading
Loading