mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
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 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.
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue