Merge pull request #14296 from colega/fix-matcher-string-with-empty-label-name

Fix `Matcher.String()` with empty label name
This commit is contained in:
Bryan Boreham 2024-06-19 06:28:53 -04:00 committed by GitHub
commit 5c417684f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -101,7 +101,7 @@ func (m *Matcher) shouldQuoteName() bool {
} }
return true return true
} }
return false return len(m.Name) == 0
} }
// Matches returns whether the matcher matches the given string value. // Matches returns whether the matcher matches the given string value.

View file

@ -148,6 +148,13 @@ func TestExprString(t *testing.T) {
in: `{"_0"="1"}`, in: `{"_0"="1"}`,
out: `{_0="1"}`, out: `{_0="1"}`,
}, },
{
in: `{""="0"}`,
},
{
in: "{``=\"0\"}",
out: `{""="0"}`,
},
} }
for _, test := range inputs { for _, test := range inputs {