mirror of
https://github.com/Skallwar/suckit.git
synced 2026-09-10 07:16:19 -04:00
Find url return string, not url
Need to change
This commit is contained in:
parent
c43ba93e23
commit
358db4cea6
|
|
@ -1,12 +1,11 @@
|
|||
use regex::Regex;
|
||||
use reqwest::Url;
|
||||
|
||||
pub fn find_urls(str: String) -> Vec<Url> {
|
||||
pub fn find_urls(str: String) -> Vec<String> {
|
||||
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"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue