Take another approach

Signed-off-by: gotjosh <josue.abreu@gmail.com>
This commit is contained in:
gotjosh 2022-09-30 11:51:17 +01:00
parent 05f073f42f
commit bd89550ce2
No known key found for this signature in database
GPG Key ID: A6E1DDE38FF3C74E
2 changed files with 6 additions and 7 deletions

View File

@ -120,18 +120,14 @@ func ParseMatcher(s string) (_ *Matcher, err error) {
return nil, errors.Errorf("bad matcher format: %s", s) return nil, errors.Errorf("bad matcher format: %s", s)
} }
rawValue := ms[3]
if len(rawValue) == 0 {
return nil, errors.Errorf("matcher value is not present: %s", s)
}
var ( var (
rawValue = ms[3]
value strings.Builder value strings.Builder
escaped bool escaped bool
expectTrailingQuote bool expectTrailingQuote bool
) )
if rawValue[0] == '"' { if strings.HasPrefix(rawValue, "\"") {
rawValue = strings.TrimPrefix(rawValue, "\"") rawValue = strings.TrimPrefix(rawValue, "\"")
expectTrailingQuote = true expectTrailingQuote = true
} }

View File

@ -191,7 +191,10 @@ func TestMatchers(t *testing.T) {
}, },
{ {
input: `job=`, input: `job=`,
err: `matcher value is not present: job=`, want: func() []*Matcher {
m, _ := NewMatcher(MatchEqual, "job", "")
return []*Matcher{m}
}(),
}, },
{ {
input: `job="value`, input: `job="value`,