tsk-22: Add function to parse env variable to a vector of strings #25

Merged
phoenix merged 8 commits from tsk-22 into main 2025-10-10 19:14:15 +00:00
2 changed files with 4 additions and 2 deletions
Showing only changes of commit 797430c9d2 - Show all commits

View File

@@ -1,4 +1,6 @@
pub fn split_words(var: &crate::EnvVar) -> Result<Vec<String>, std::io::Error> { /// Take the Environment variable and delimitize it. If the value has a delimiter,
/// extract it into some strings
pub fn delimitize(var: &crate::EnvVar) -> Result<Vec<String>, std::io::Error> {
if var.has_delimiter { if var.has_delimiter {
Ok(var.value.split(var.delimiter).map(|c| c.parse::<String>().unwrap()).collect()) Ok(var.value.split(var.delimiter).map(|c| c.parse::<String>().unwrap()).collect())
} else { } else {

View File

@@ -118,7 +118,7 @@ mod tests {
assert_eq!(result.has_delimiter, true, "The {} variable has an issue finding the delimiter", result.key); assert_eq!(result.has_delimiter, true, "The {} variable has an issue finding the delimiter", result.key);
match icarus_envy::utility::split_words(&result) { match icarus_envy::utility::delimitize(&result) {
Ok(allowed_origins) => { Ok(allowed_origins) => {
assert_eq!(allowed_origins.len(), 2, "The amount of allowed origins does not match. {} {}", allowed_origins.len(), 2) assert_eq!(allowed_origins.len(), 2, "The amount of allowed origins does not match. {} {}", allowed_origins.len(), 2)
} }