diff --git a/lychee-bin/src/commands/check.rs b/lychee-bin/src/commands/check.rs index 5c0614b..b5cae77 100644 --- a/lychee-bin/src/commands/check.rs +++ b/lychee-bin/src/commands/check.rs @@ -320,7 +320,7 @@ async fn handle( fn ignore_cache(uri: &Uri, status: &Status, cache_exclude_status: &HashSet) -> bool { let status_code_excluded = status .code() - .map_or(false, |code| cache_exclude_status.contains(&code.as_u16())); + .is_some_and(|code| cache_exclude_status.contains(&code.as_u16())); uri.is_file() || status.is_excluded() diff --git a/lychee-bin/src/main.rs b/lychee-bin/src/main.rs index 521a9b8..fea752a 100644 --- a/lychee-bin/src/main.rs +++ b/lychee-bin/src/main.rs @@ -294,7 +294,7 @@ async fn run(opts: &LycheeOptions) -> Result { .skip_ignored(!opts.config.no_ignore) .include_verbatim(opts.config.include_verbatim) // File a bug if you rely on this envvar! It's going to go away eventually. - .use_html5ever(std::env::var("LYCHEE_USE_HTML5EVER").map_or(false, |x| x == "1")); + .use_html5ever(std::env::var("LYCHEE_USE_HTML5EVER").is_ok_and(|x| x == "1")); if opts.config.dump_inputs { let sources = collector.collect_sources(inputs); diff --git a/lychee-bin/tests/cli.rs b/lychee-bin/tests/cli.rs index 5479d37..9206878 100644 --- a/lychee-bin/tests/cli.rs +++ b/lychee-bin/tests/cli.rs @@ -1604,6 +1604,8 @@ mod cli { #[test] #[ignore = "Skipping test because it is flaky"] fn test_suggests_url_alternatives() -> Result<()> { + let re = Regex::new(r"http://web\.archive\.org/web/.*google\.com/jobs\.html").unwrap(); + for _ in 0..3 { // This can be flaky. Try up to 3 times let mut cmd = main_command(); @@ -1619,7 +1621,6 @@ mod cli { // We're looking for a suggestion that // - starts with http://web.archive.org/web/ // - ends with google.com/jobs.html - let re = Regex::new(r"http://web\.archive\.org/web/.*google\.com/jobs\.html").unwrap(); if re.is_match(&String::from_utf8_lossy(&output.stdout)) { // Test passed return Ok(()); diff --git a/lychee-lib/src/extract/html/html5gum.rs b/lychee-lib/src/extract/html/html5gum.rs index 7fc03f7..441e196 100644 --- a/lychee-lib/src/extract/html/html5gum.rs +++ b/lychee-lib/src/extract/html/html5gum.rs @@ -169,7 +169,7 @@ impl LinkExtractor { return; } - if self.current_attributes.get("rel").map_or(false, |rel| { + if self.current_attributes.get("rel").is_some_and(|rel| { rel.split(',').any(|r| { r.trim() == "nofollow" || r.trim() == "preconnect" || r.trim() == "dns-prefetch" }) @@ -189,7 +189,7 @@ impl LinkExtractor { if self .current_attributes .get("rel") - .map_or(false, |rel| rel.contains("stylesheet")) + .is_some_and(|rel| rel.contains("stylesheet")) { if let Some(href) = self.current_attributes.get("href") { if href.starts_with("/@") || href.starts_with('@') { diff --git a/lychee-lib/src/filter/mod.rs b/lychee-lib/src/filter/mod.rs index a6cda08..f5f0165 100644 --- a/lychee-lib/src/filter/mod.rs +++ b/lychee-lib/src/filter/mod.rs @@ -74,7 +74,7 @@ pub fn is_example_domain(uri: &Uri) -> bool { domain == example || domain .split_once('.') - .map_or(false, |(_subdomain, tld_part)| tld_part == example) + .is_some_and(|(_subdomain, tld_part)| tld_part == example) }) || EXAMPLE_TLDS .iter() .any(|&example_tld| domain.ends_with(example_tld)) diff --git a/lychee-lib/src/retry.rs b/lychee-lib/src/retry.rs index 36db0c3..f6333c1 100644 --- a/lychee-lib/src/retry.rs +++ b/lychee-lib/src/retry.rs @@ -88,7 +88,7 @@ impl RetryExt for http::Error { inner .source() .and_then(<(dyn std::error::Error + 'static)>::downcast_ref) - .map_or(false, should_retry_io) + .is_some_and(should_retry_io) } } diff --git a/lychee-lib/src/types/file.rs b/lychee-lib/src/types/file.rs index d2f8631..eb1ea35 100644 --- a/lychee-lib/src/types/file.rs +++ b/lychee-lib/src/types/file.rs @@ -57,9 +57,7 @@ impl> From

for FileType { fn is_url(path: &Path) -> bool { path.to_str() .and_then(|s| Url::parse(s).ok()) - .map_or(false, |url| { - url.scheme() == "http" || url.scheme() == "https" - }) + .is_some_and(|url| url.scheme() == "http" || url.scheme() == "https") } #[cfg(test)]