diff --git a/common/expr/eval_test.go b/common/expr/eval_test.go index bbb8ab043c..c03309957b 100644 --- a/common/expr/eval_test.go +++ b/common/expr/eval_test.go @@ -41,6 +41,7 @@ func TestEvalBool(t *testing.T) { "email": "johndoe@intuit.com", "gender": "Male", "dept": "devp", + "uuid": "test-case-hyphen", } pass, err := EvalBool("(id == 1) && (last_name == 'Doe')", env) @@ -54,4 +55,9 @@ func TestEvalBool(t *testing.T) { pass, err = EvalBool("invalidexpression", env) assert.Error(t, err) assert.False(t, pass) + + // expr with '-' evaluate the same as others + pass, err = EvalBool("(uuid == 'test-case-hyphen')", env) + assert.NoError(t, err) + assert.True(t, pass) } diff --git a/eventsources/eventing.go b/eventsources/eventing.go index 8f7916f646..630ce54df2 100644 --- a/eventsources/eventing.go +++ b/eventsources/eventing.go @@ -565,5 +565,5 @@ func filterEvent(data []byte, filter *v1alpha1.EventSourceFilter) (bool, error) params[strings.ReplaceAll(key, "-", "_")] = value } env := expr.GetFuncMap(params) - return expr.EvalBool(strings.ReplaceAll(filter.Expression, "-", "_"), env) + return expr.EvalBool(filter.Expression, env) }