Skip to content

Commit

Permalink
Merge pull request #54 from codertao/master
Browse files Browse the repository at this point in the history
Trim spaces in CSV env vars
  • Loading branch information
softprops committed Dec 27, 2021
2 parents 433fcd5 + aac75b8 commit 801d81e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ impl<'de> de::Deserializer<'de> for Val {
if self.1.is_empty() {
SeqDeserializer::new(empty::<Val>()).deserialize_seq(visitor)
} else {
let values = self.1.split(',').map(|v| Val(self.0.clone(), v.to_owned()));
let values = self
.1
.split(',')
.map(|v| Val(self.0.clone(), v.trim().to_owned()));
SeqDeserializer::new(values).deserialize_seq(visitor)
}
}
Expand Down Expand Up @@ -426,7 +429,7 @@ mod tests {
let data = vec![
(String::from("BAR"), String::from("test")),
(String::from("BAZ"), String::from("true")),
(String::from("DOOM"), String::from("1,2,3")),
(String::from("DOOM"), String::from("1, 2, 3 ")),
// Empty string should result in empty vector.
(String::from("BOOM"), String::from("")),
(String::from("SIZE"), String::from("small")),
Expand Down

0 comments on commit 801d81e

Please sign in to comment.