diff --git a/src/parser.rs b/src/parser.rs index 017f6a4..4df97c0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,12 +1,11 @@ use regex::Regex; use reqwest::Url; -pub fn find_urls(str: String) -> Vec { +pub fn find_urls(str: String) -> Vec { let regex = Regex::new(r#"(href|src) *= *"([^ "]*)""#).unwrap(); regex .captures_iter(&str) - .map(|matched| Url::parse(&matched[2])) - .filter_map(Result::ok) + .map(|matched| String::from(&matched[2])) .collect() } @@ -17,6 +16,6 @@ mod tests { #[test] fn test_find_href_url() { let vec = find_urls("href= \"https://lol.com\"\nsrc = \"ulr2\"".to_string()); - assert_eq!(vec, [Url::parse("https://lol.com").unwrap()]); + assert_eq!(vec, ["https://lol.com", "url2"]); } }