Fix Matcher.String() with empty label name
When the label name is empty, which can happen now with quoted label name, it should be quoted when printed as a string again. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
parent
5a218708f1
commit
03cf6141d4
|
@ -101,7 +101,7 @@ func (m *Matcher) shouldQuoteName() bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return len(m.Name) == 0
|
||||
}
|
||||
|
||||
// Matches returns whether the matcher matches the given string value.
|
||||
|
|
|
@ -148,6 +148,13 @@ func TestExprString(t *testing.T) {
|
|||
in: `{"_0"="1"}`,
|
||||
out: `{_0="1"}`,
|
||||
},
|
||||
{
|
||||
in: `{""="0"}`,
|
||||
},
|
||||
{
|
||||
in: "{``=\"0\"}",
|
||||
out: `{""="0"}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range inputs {
|
||||
|
|
Loading…
Reference in New Issue