Skip to content

Commit

Permalink
also special case integers
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Jun 4, 2024
1 parent eed336e commit 5795a2d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,17 @@ impl SelectorConfig {
);

for (key, v) in self.variant {
match v.to_lowercase().as_str() {
"true" => context.insert(key.clone(), Value::from(true)),
"false" => context.insert(key.clone(), Value::from(false)),
_ => context.insert(key, Value::from_safe_string(v)),
let v_lower = v.to_lowercase();
match v_lower.as_str() {
"true" | "yes" => context.insert(key.clone(), Value::from(true)),
"false" | "no" => context.insert(key.clone(), Value::from(false)),
_ => {
if let Ok(v_num) = v.parse::<i64>() {
context.insert(key.clone(), Value::from(v_num))
} else {
context.insert(key.clone(), Value::from_safe_string(v))
}
}
};
}

Expand Down

0 comments on commit 5795a2d

Please sign in to comment.