diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f59486f..136edd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.10.2 (unreleased) + +- Fix link checker not looking for anchor with capital id/name + ## 0.10.1 (2020-03-12) - Set user agent for HTTP requests diff --git a/components/link_checker/src/lib.rs b/components/link_checker/src/lib.rs index e9b038bc..7ecd6ca8 100644 --- a/components/link_checker/src/lib.rs +++ b/components/link_checker/src/lib.rs @@ -118,11 +118,15 @@ fn has_anchor(url: &str) -> bool { fn check_page_for_anchor(url: &str, body: String) -> Result<()> { let index = url.find('#').unwrap(); let anchor = url.get(index + 1..).unwrap(); - let checks: [String; 4] = [ + let checks: [String; 8] = [ format!(" id='{}'", anchor), + format!(" ID='{}'", anchor), format!(r#" id="{}""#, anchor), + format!(r#" ID="{}""#, anchor), format!(" name='{}'", anchor), + format!(" NAME='{}'", anchor), format!(r#" name="{}""#, anchor), + format!(r#" NAME="{}""#, anchor), ]; if checks.iter().any(|check| body[..].contains(&check[..])) { @@ -272,6 +276,15 @@ mod tests { assert!(res.is_ok()); } + // https://github.com/getzola/zola/issues/948 + #[test] + fn can_validate_anchors_in_capital() { + let url = "https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect"; + let body = r#"