diff --git a/components/link_checker/src/lib.rs b/components/link_checker/src/lib.rs index 811c72d9..5ed0935a 100644 --- a/components/link_checker/src/lib.rs +++ b/components/link_checker/src/lib.rs @@ -101,11 +101,15 @@ fn has_anchor(url: &str) -> bool { fn check_page_for_anchor(url: &str, body: String) -> errors::Result<()> { let index = url.find('#').unwrap(); let anchor = url.get(index + 1..).unwrap(); - let checks: [String; 8] = [ + let checks = [ + format!(" id={}", anchor), + format!(" ID={}", anchor), format!(" id='{}'", anchor), format!(" ID='{}'", anchor), format!(r#" id="{}""#, anchor), format!(r#" ID="{}""#, anchor), + format!(" name={}", anchor), + format!(" NAME={}", anchor), format!(" name='{}'", anchor), format!(" NAME='{}'", anchor), format!(r#" name="{}""#, anchor), @@ -256,7 +260,7 @@ mod tests { } #[test] - fn can_validate_anchors() { + fn can_validate_anchors_with_double_quotes() { let url = "https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect"; let body = r#"

collect

"#.to_string(); let res = check_page_for_anchor(url, body); @@ -273,9 +277,17 @@ mod tests { } #[test] - fn can_validate_anchors_with_other_quotes() { + fn can_validate_anchors_with_single_quotes() { let url = "https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect"; - let body = r#"

collect

"#.to_string(); + let body = "

collect

".to_string(); + let res = check_page_for_anchor(url, body); + assert!(res.is_ok()); + } + + #[test] + fn can_validate_anchors_without_quotes() { + let url = "https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect"; + let body = "

collect

".to_string(); let res = check_page_for_anchor(url, body); assert!(res.is_ok()); }