diff --git a/src/extract.rs b/src/extract.rs index 08ed5d9..29c0b6b 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -1,4 +1,4 @@ -use linkify::{LinkFinder, LinkKind}; +use linkify::LinkFinder; use std::collections::HashSet; use url::Url; @@ -11,7 +11,7 @@ pub(crate) fn extract_links(input: &str) -> HashSet { // Silently ignore the parse failures for now. // TODO: Log errors in verbose mode let links: HashSet = links.iter().flat_map(|l| Url::parse(l.as_str())).collect(); - debug!("Testing links: {:#?}", links); + debug!("Found links: {:#?}", links); links } @@ -23,8 +23,8 @@ mod test { #[test] fn test_extract_markdown_links() { - let md = "This is [a test](https://endler.dev)."; - let links = extract_links(md); + let input = "This is [a test](https://endler.dev)."; + let links = extract_links(input); assert_eq!( links, HashSet::from_iter([Url::parse("https://endler.dev").unwrap()].iter().cloned()) @@ -33,22 +33,22 @@ mod test { #[test] fn test_skip_markdown_anchors() { - let md = "This is [a test](#lol)."; - let links = extract_links(md); + let input = "This is [a test](#lol)."; + let links = extract_links(input); assert_eq!(links, HashSet::new()) } #[test] fn test_skip_markdown_iternal_urls() { - let md = "This is [a test](./internal)."; - let links = extract_links(md); + let input = "This is [a test](./internal)."; + let links = extract_links(input); assert_eq!(links, HashSet::new()) } #[test] fn test_non_markdown_links() { - let md = "https://endler.dev and https://hello-rust.show/foo/bar?lol=1"; - let links = extract_links(md); + let input = "https://endler.dev and https://hello-rust.show/foo/bar?lol=1"; + let links = extract_links(input); let expected = HashSet::from_iter( [ Url::parse("https://endler.dev").unwrap(), @@ -59,4 +59,11 @@ mod test { ); assert_eq!(links, expected) } + + #[test] + fn test_skip_emails() { + let input = "matthias@example.com"; + let links = extract_links(input); + assert_eq!(links, HashSet::new()) + } }