Skip to content

Commit

Permalink
Add missing clear statement and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Aug 22, 2023
1 parent 2fb3466 commit f04d127
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lychee-lib/src/extract/html/html5ever.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,14 @@ mod tests {
let uris = extract_html(input, false);
assert!(uris.is_empty());
}

#[test]
fn test_skip_preconnect_reverse_order() {
let input = r#"
<link href="https://example.com" rel="preconnect">
"#;

let uris = extract_html(input, false);
assert!(uris.is_empty());
}
}
22 changes: 21 additions & 1 deletion lychee-lib/src/extract/html/html5gum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ impl Emitter for &mut LinkExtractor {
self.flush_current_characters();
self.current_element_name.clear();
self.current_element_nofollow = false;
self.current_element_preconnect = false;
self.current_element_is_closing = false;
}

Expand Down Expand Up @@ -404,7 +405,7 @@ mod tests {
}

#[test]
fn test_include_nofollow() {
fn test_exclude_nofollow() {
let input = r#"
<a rel="nofollow" href="https://foo.com">do not follow me</a>
<a rel="canonical,nofollow,dns-prefetch" href="https://example.com">do not follow me</a>
Expand All @@ -419,6 +420,15 @@ mod tests {
assert_eq!(uris, expected);
}

#[test]
fn test_exclude_nofollow_change_order() {
let input = r#"
<a href="https://foo.com" rel="nofollow">do not follow me</a>
"#;
let uris = extract_html(input, false);
assert!(uris.is_empty());
}

#[test]
fn test_exclude_script_tags() {
let input = r#"
Expand Down Expand Up @@ -528,4 +538,14 @@ mod tests {
let uris = extract_html(input, false);
assert!(uris.is_empty());
}

#[test]
fn test_skip_preconnect_reverse_order() {
let input = r#"
<link href="https://example.com" rel="preconnect">
"#;

let uris = extract_html(input, false);
assert!(uris.is_empty());
}
}

0 comments on commit f04d127

Please sign in to comment.