mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
Add check to ensure parsed URL equals link
This commit is contained in:
parent
6ef52726da
commit
503bdb8c22
1 changed files with 22 additions and 12 deletions
|
@ -70,18 +70,28 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn check_page(page: HelpPage, ctx: &BasicContext) -> Outcome {
|
async fn check_page(page: HelpPage, ctx: &BasicContext) -> Outcome {
|
||||||
match Url::parse(&page.to_link()) {
|
let link = page.to_link();
|
||||||
Ok(url) => match check_web(&url, ctx).await {
|
match Url::parse(&link) {
|
||||||
Ok(()) => Outcome::Valid,
|
Ok(url) => {
|
||||||
Err(Reason::Dom) => Outcome::Invalid(format!(
|
if url.as_str() == link {
|
||||||
"'#{}' not found on '{}{}'",
|
match check_web(&url, ctx).await {
|
||||||
url.fragment().unwrap(),
|
Ok(()) => Outcome::Valid,
|
||||||
url.domain().unwrap(),
|
Err(Reason::Dom) => Outcome::Invalid(format!(
|
||||||
url.path(),
|
"'#{}' not found on '{}{}'",
|
||||||
)),
|
url.fragment().unwrap(),
|
||||||
Err(Reason::Web(err)) => Outcome::Invalid(err.to_string()),
|
url.domain().unwrap(),
|
||||||
_ => unreachable!(),
|
url.path(),
|
||||||
},
|
)),
|
||||||
|
Err(Reason::Web(err)) => Outcome::Invalid(err.to_string()),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Outcome::Invalid(format!(
|
||||||
|
"'{}' is not a valid URL part",
|
||||||
|
page.to_link_suffix(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(err) => Outcome::Invalid(err.to_string()),
|
Err(err) => Outcome::Invalid(err.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue