mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-10 23:03:11 +00:00
Exclude known false-positives from Github API check (#445)
Fixes https://github.com/lycheeverse/lychee/issues/431
This commit is contained in:
parent
d9af0817e5
commit
388bbbe7b0
3 changed files with 35 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1761,6 +1761,7 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"hubcaps",
|
"hubcaps",
|
||||||
"jwalk",
|
"jwalk",
|
||||||
|
"lazy_static",
|
||||||
"linkify",
|
"linkify",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ cached = "0.26.2"
|
||||||
once_cell = "1.9.0"
|
once_cell = "1.9.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
futures = "0.3.19"
|
futures = "0.3.19"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
[dependencies.par-stream]
|
[dependencies.par-stream]
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{convert::TryFrom, fmt::Display, net::IpAddr};
|
use std::{collections::HashSet, convert::TryFrom, fmt::Display, net::IpAddr};
|
||||||
|
|
||||||
use fast_chemail::parse_email;
|
use fast_chemail::parse_email;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
|
@ -8,6 +9,16 @@ use crate::{ErrorKind, Result};
|
||||||
|
|
||||||
use super::raw_uri::RawUri;
|
use super::raw_uri::RawUri;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref GITHUB_EXCLUDED_ORGS: HashSet<&'static str> = {
|
||||||
|
let mut m = HashSet::new();
|
||||||
|
m.insert("sponsors");
|
||||||
|
m.insert("marketplace");
|
||||||
|
m.insert("features");
|
||||||
|
m
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Lychee's own representation of a URI, which encapsulates all supported
|
/// Lychee's own representation of a URI, which encapsulates all supported
|
||||||
/// formats.
|
/// formats.
|
||||||
///
|
///
|
||||||
|
|
@ -75,9 +86,12 @@ impl Uri {
|
||||||
self.domain()?,
|
self.domain()?,
|
||||||
"github.com" | "www.github.com" | "raw.githubusercontent.com"
|
"github.com" | "www.github.com" | "raw.githubusercontent.com"
|
||||||
) {
|
) {
|
||||||
let mut path = self.path_segments()?;
|
let mut segments = self.path_segments()?;
|
||||||
let owner = path.next()?;
|
let owner = segments.next()?;
|
||||||
let repo = path.next()?;
|
if GITHUB_EXCLUDED_ORGS.contains(owner) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let repo = segments.next()?;
|
||||||
return Some((owner, repo));
|
return Some((owner, repo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,6 +257,21 @@ mod test {
|
||||||
Some(("lycheeverse", "lychee"))
|
Some(("lycheeverse", "lychee"))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check known false positives
|
||||||
|
assert!(website("https://github.com/sponsors/analysis-tools-dev ")
|
||||||
|
.extract_github()
|
||||||
|
.is_none());
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
website("https://github.com/marketplace/actions/lychee-broken-link-checker")
|
||||||
|
.extract_github()
|
||||||
|
.is_none()
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(website("https://github.com/features/actions")
|
||||||
|
.extract_github()
|
||||||
|
.is_none());
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
website("https://pkg.go.dev/github.com/Debian/pkg-go-tools/cmd/pgt-gopath")
|
website("https://pkg.go.dev/github.com/Debian/pkg-go-tools/cmd/pgt-gopath")
|
||||||
.extract_github()
|
.extract_github()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue