diff options
author | elandsborough <elliott.landsborough@gmail.com> | 2024-01-10 19:53:36 +0000 |
---|---|---|
committer | ElliottLandsborough <elliott.landsborough@gmail.com> | 2024-01-13 03:28:24 +0000 |
commit | e5e3ad2fed80bea3f2c9c90f87a405bca077691e (patch) | |
tree | 80c37e10ad52880d35efb55fbead0f17afa83323 /tests/utils/mod.rs | |
parent | Skip newline test case on Windows (diff) | |
download | miniserve-e5e3ad2fed80bea3f2c9c90f87a405bca077691e.tar.gz miniserve-e5e3ad2fed80bea3f2c9c90f87a405bca077691e.zip |
Set default sorting order and method with arguments
Diffstat (limited to 'tests/utils/mod.rs')
-rw-r--r-- | tests/utils/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs index 734d33b..64433fc 100644 --- a/tests/utils/mod.rs +++ b/tests/utils/mod.rs @@ -12,3 +12,19 @@ pub fn get_link_from_text(document: &Document, text: &str) -> Option<String> { .next()?; 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> { + let mut vec: Vec<String> = Vec::new(); + + let a_elem = 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()); + } + } + + return vec; +} |