diff --git a/components/utils/src/anchors.rs b/components/utils/src/anchors.rs index 642e58937f..06af56b47b 100644 --- a/components/utils/src/anchors.rs +++ b/components/utils/src/anchors.rs @@ -6,7 +6,7 @@ pub fn has_anchor_id(content: &str, anchor: &str) -> bool { } fn anchor_id_checks(anchor: &str) -> Regex { - Regex::new(&format!(r#" (?i)(id|name) *= *("|')*{}("|'| |>)+"#, anchor)).unwrap() + Regex::new(&format!(r#"\s(?i)(id|name) *= *("|')*{}("|'| |>)+"#, anchor)).unwrap() } #[cfg(test)] @@ -39,5 +39,12 @@ mod tests { // Case variants assert!(m(r#""#)); assert!(m(r#""#)); + + // Newline variants + assert!(m(r#""#)); + + // Non matchers + assert!(!m(r#""#)) } }