Support matching boolean values with regex

This commit is contained in:
finga 2021-04-22 11:52:02 +02:00
parent d552e29e8f
commit 280dab6e8c
3 changed files with 4 additions and 3 deletions

2
Cargo.lock generated
View file

@ -1202,7 +1202,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "webhookey"
version = "0.1.0-rc.0"
version = "0.1.0-rc.1"
dependencies = [
"anyhow",
"dirs",

View file

@ -1,6 +1,6 @@
[package]
name = "webhookey"
version = "0.1.0-rc.0"
version = "0.1.0-rc.1"
authors = ["finga <webhookey@onders.org>"]
edition = "2018"
license = "GPL-3.0-or-later"

View file

@ -204,7 +204,7 @@ fn replace_parameter(input: &str, headers: &HeaderMap, data: &serde_json::Value)
fn get_string(value: &serde_json::Value) -> Result<String> {
match &value {
serde_json::Value::Null => unimplemented!(),
serde_json::Value::Bool(_bool) => unimplemented!(),
serde_json::Value::Bool(bool) => Ok(bool.to_string()),
serde_json::Value::Number(number) => Ok(number.to_string()),
serde_json::Value::String(string) => Ok(string.as_str().to_string()),
serde_json::Value::Array(_array) => unimplemented!(),
@ -229,6 +229,7 @@ fn filter_match(
if let Some(json_value) = data.pointer(parameter) {
*data.pointer_mut(parameter).unwrap() = match json_value {
serde_json::Value::Bool(bool) => serde_json::Value::String(bool.to_string()),
serde_json::Value::String(string) => serde_json::Value::String(string.to_string()),
serde_json::Value::Number(number) => serde_json::Value::String(number.to_string()),
x => {