Skip to content

Commit

Permalink
check for empty criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerboa-app committed Jan 25, 2024
1 parent eab56b5 commit 8d07fd2
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/web/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,40 @@ pub fn expand_template(template: String, data: HashMap<String, serde_json::Value

pub fn satisfied(criterion: Criterion, data: &HashMap<String, serde_json::Value>) -> bool
{

if criterion.check_value_path == ""
{
return true
}

let path: Vec<&str> = criterion.check_value_path.split("/").collect();

let extracted_value= match path.len()
{
0 => None,
1 => Some(&data[path[0]]),
1 =>
{
if data.contains_key(path[0])
{
Some(&data[path[0]])
}
else
{
None
}
},
_ =>
{
let p = ["/", &path[1..path.len()].join("/")].join("");
data[path[0]].pointer(&p)
if data.contains_key(path[0])
{
data[path[0]].pointer(&p)
}
else
{
None
}

}
};

Expand Down

0 comments on commit 8d07fd2

Please sign in to comment.