mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
Merge pull request #14257 from grafana/davkal/fix-14250
Explore: Fix logging query parser for regex with quantifiers
This commit is contained in:
commit
d16b348868
@ -42,4 +42,15 @@ describe('parseQuery', () => {
|
|||||||
regexp: '',
|
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}',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const selectorRegexp = /{[^{]*}/g;
|
const selectorRegexp = /(?:^|\s){[^{]*}/g;
|
||||||
export function parseQuery(input: string) {
|
export function parseQuery(input: string) {
|
||||||
const match = input.match(selectorRegexp);
|
const match = input.match(selectorRegexp);
|
||||||
let query = '';
|
let query = '';
|
||||||
let regexp = input;
|
let regexp = input;
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
query = match[0];
|
query = match[0].trim();
|
||||||
regexp = input.replace(selectorRegexp, '').trim();
|
regexp = input.replace(selectorRegexp, '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user