Don't fall over on unknown schemes e.g. mailto:
This commit is contained in:
parent
c940900fab
commit
4bba2fc89b
@ -6,6 +6,10 @@ use quickpeep_utils::dates::date_to_quickpeep_days;
|
||||
use reqwest::Url;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
/// Supported schemes.
|
||||
/// References in all other schemes will be ignored.
|
||||
pub const SUPPORTED_SCHEMES: [&'static str; 2] = ["http", "https"];
|
||||
|
||||
pub fn find_references(
|
||||
doc: &Vec<DenseTree>,
|
||||
feeds: &Vec<Url>,
|
||||
@ -41,11 +45,18 @@ pub fn find_references(
|
||||
} => {
|
||||
if !nofollow {
|
||||
if let Ok(full_url) = page_url.join(&href) {
|
||||
refs.insert(RakedReference {
|
||||
target: clean_url(&full_url).to_string(),
|
||||
kind: ReferenceKind::Link,
|
||||
last_mod: None,
|
||||
});
|
||||
if SUPPORTED_SCHEMES.contains(&full_url.scheme()) {
|
||||
refs.insert(RakedReference {
|
||||
target: clean_url(&full_url).to_string(),
|
||||
kind: ReferenceKind::Link,
|
||||
last_mod: None,
|
||||
});
|
||||
} else {
|
||||
debug!(
|
||||
"ignoring reference {:?}: not a supported scheme",
|
||||
full_url.as_str()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
debug!("Can't join {:?} + {:?} to get full URL", page_url, href);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user