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 Sep 28, 2024
1 parent c07329d commit cb2a17a
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 @@ -400,4 +400,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 @@ -238,6 +238,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 @@ -433,7 +434,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 @@ -448,6 +449,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 @@ -579,4 +589,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 cb2a17a

Please sign in to comment.