Commit d16b3488 by Torkel Ödegaard Committed by GitHub

Merge pull request #14257 from grafana/davkal/fix-14250

Explore: Fix logging query parser for regex with quantifiers
parents 246c1ca7 11a53763
......@@ -42,4 +42,15 @@ describe('parseQuery', () => {
regexp: '',
});
});
it('returns query and regexp with quantifiers', () => {
expect(parseQuery('{foo="bar"} \\.java:[0-9]{1,5}')).toEqual({
query: '{foo="bar"}',
regexp: '\\.java:[0-9]{1,5}',
});
expect(parseQuery('\\.java:[0-9]{1,5} {foo="bar"}')).toEqual({
query: '{foo="bar"}',
regexp: '\\.java:[0-9]{1,5}',
});
});
});
const selectorRegexp = /{[^{]*}/g;
const selectorRegexp = /(?:^|\s){[^{]*}/g;
export function parseQuery(input: string) {
const match = input.match(selectorRegexp);
let query = '';
let regexp = input;
if (match) {
query = match[0];
query = match[0].trim();
regexp = input.replace(selectorRegexp, '').trim();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment