diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2024-01-13 05:11:59 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2024-01-13 05:11:59 +0000 |
commit | 562b62a0b638d2ca0731f83476a2e5f74757962a (patch) | |
tree | 2073b8249218f86e95d57b7734310495cb7db109 /tests/utils/mod.rs | |
parent | Fix formatting (diff) | |
download | miniserve-562b62a0b638d2ca0731f83476a2e5f74757962a.tar.gz miniserve-562b62a0b638d2ca0731f83476a2e5f74757962a.zip |
Clean up default order function
I removed the stringly typing as we already have enums for this that we can make use of.
Diffstat (limited to 'tests/utils/mod.rs')
-rw-r--r-- | tests/utils/mod.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs index 64433fc..baffc29 100644 --- a/tests/utils/mod.rs +++ b/tests/utils/mod.rs @@ -13,16 +13,16 @@ pub fn get_link_from_text(document: &Document, text: &str) -> Option<String> { Some(a_elem.attr("href")?.to_string()) } -/// Return the href attributes of all links that start with the specified prefix `text`. -pub fn get_link_hrefs_from_text_with_prefix(document: &Document, text: &str) -> Vec<String> { +/// Return the href attributes of all links that start with the specified `prefix`. +pub fn get_link_hrefs_with_prefix(document: &Document, prefix: &str) -> Vec<String> { let mut vec: Vec<String> = Vec::new(); - let a_elem = document.find(Name("a")); + let a_elements = document.find(Name("a")); - for element in a_elem { - let str = element.attr("href").unwrap_or(""); - if str.to_string().starts_with(text) { - vec.push(str.to_string()); + for element in a_elements { + let s = element.attr("href").unwrap_or(""); + if s.to_string().starts_with(prefix) { + vec.push(s.to_string()); } } |