Alerting: Fix matching labels with spaces in their values (#68909)
Fix matching labels with spaces in their values
This commit is contained in:
@@ -85,6 +85,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', () => {
|
it('should return nothing for invalid operator', () => {
|
||||||
expect(parseMatchers('foo=!bar')).toEqual([]);
|
expect(parseMatchers('foo=!bar')).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export function matcherToObjectMatcher(matcher: Matcher): ObjectMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function parseMatchers(matcherQueryString: string): Matcher[] {
|
export function parseMatchers(matcherQueryString: string): Matcher[] {
|
||||||
const matcherRegExp = /\b([\w.-]+)(=~|!=|!~|=(?="?\w))"?([^"\n,} ]*)"?/g;
|
const matcherRegExp = /\b([\w.-]+)(=~|!=|!~|=(?="?\w))"?([^"\n,}]*)"?/g;
|
||||||
const matchers: Matcher[] = [];
|
const matchers: Matcher[] = [];
|
||||||
|
|
||||||
matcherQueryString.replace(matcherRegExp, (_, key, operator, value) => {
|
matcherQueryString.replace(matcherRegExp, (_, key, operator, value) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user