Skip to content

Commit

Permalink
just return nil filtering group if parse string is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
shinmog committed Apr 8, 2024
1 parent a5279df commit 216d850
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion filtering/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Parse(s string, quote string) (*Group, error) {
} else if quote == "&" || quote == "|" || quote == "(" || quote == ")" || quote == " " || quote == `\` || quote == "!" || quote == "." || quote == "<" || quote == ">" || quote == "=" || quote == "-" || quote == "_" {
return nil, fmt.Errorf("quote character cannot be a reserved character")
} else if s == "" {
return nil, fmt.Errorf("logic string is empty")
return nil, nil
}

var ch rune
Expand Down
10 changes: 9 additions & 1 deletion filtering/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,6 @@ func TestParseReturnsError(t *testing.T) {
"foobar",
"(",
")",
"",
}

for _, s := range checks {
Expand Down Expand Up @@ -966,3 +965,12 @@ func TestParseWithInvalidQuoteReturnsError(t *testing.T) {
}
}
}

func TestParseEmptyString(t *testing.T) {
resp, err := Parse("", `"`)
if err != nil {
t.Fatalf("parse empty string error: %s", err)
} else if resp != nil {
t.Fatalf("parse empty string has non-nil group")
}
}

0 comments on commit 216d850

Please sign in to comment.