[v9.5.x] Alerting: Fix matching labels with spaces in their values (#69339)
Alerting: Fix matching labels with spaces in their values (#68909)
Fix matching labels with spaces in their values
(cherry picked from commit fb7993d021)
Co-authored-by: Virginia Cepeda <virginia.cepeda@grafana.com>
This commit is contained in:
co-authored by
Virginia Cepeda
parent
0f9f72d46b
commit
a3c8fd3e9b
@@ -90,6 +90,17 @@ describe('Alertmanager utils', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should parse with spaces in the value', () => {
|
||||
expect(parseMatchers('foo=bar bazz')).toEqual<Matcher[]>([
|
||||
{
|
||||
name: 'foo',
|
||||
value: 'bar bazz',
|
||||
isRegex: false,
|
||||
isEqual: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return nothing for invalid operator', () => {
|
||||
expect(parseMatchers('foo=!bar')).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -165,7 +165,7 @@ export function matcherToObjectMatcher(matcher: Matcher): ObjectMatcher {
|
||||
}
|
||||
|
||||
export function parseMatchers(matcherQueryString: string): Matcher[] {
|
||||
const matcherRegExp = /\b([\w.-]+)(=~|!=|!~|=(?="?\w))"?([^"\n,} ]*)"?/g;
|
||||
const matcherRegExp = /\b([\w.-]+)(=~|!=|!~|=(?="?\w))"?([^"\n,}]*)"?/g;
|
||||
const matchers: Matcher[] = [];
|
||||
|
||||
matcherQueryString.replace(matcherRegExp, (_, key, operator, value) => {
|
||||
|
||||
Reference in New Issue
Block a user