diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2024-01-13 04:36:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-13 04:36:58 +0000 |
commit | c78db05996af04e52d6b16f961a8b247a60c3e88 (patch) | |
tree | 53149c8ee8aa68fa680d23e5011a4c3adfd5b5de /tests/utils | |
parent | Use tokio::fs instead of std::fs to enable async file operations (fixes #445) (diff) | |
parent | Set default sorting order and method with arguments (diff) | |
download | miniserve-c78db05996af04e52d6b16f961a8b247a60c3e88.tar.gz miniserve-c78db05996af04e52d6b16f961a8b247a60c3e88.zip |
Merge pull request #1308 from ElliottLandsborough/set_sorting_order_with_arguments
Set default sorting order and method with arguments
Diffstat (limited to 'tests/utils')
-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; +} |