mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix wrong query expression with inline comments (#70947)
fix remove comments from query
This commit is contained in:
parent
2084cc9955
commit
13dd821961
@ -161,6 +161,7 @@ describe('removeCommentsFromQuery', () => {
|
||||
${'{job="grafana", bar="baz"} |="test" | logfmt | label_format level=lvl #hello'} | ${'{job="grafana", bar="baz"} |="test" | logfmt | label_format level=lvl '}
|
||||
${`#sum(rate(\n{host="containers"}\n#[1m]))`} | ${`\n{host="containers"}\n`}
|
||||
${`#sum(rate(\n{host="containers"}\n#| logfmt\n#[1m]))`} | ${`\n{host="containers"}\n\n`}
|
||||
${'{job="grafana"}\n#hello\n| logfmt'} | ${'{job="grafana"}\n\n| logfmt'}
|
||||
`('strips comments in log query: {$query}', ({ query, expectedResult }) => {
|
||||
expect(removeCommentsFromQuery(query)).toBe(expectedResult);
|
||||
});
|
||||
|
@ -241,6 +241,7 @@ export function removeCommentsFromQuery(query: string): string {
|
||||
newQuery = newQuery + query.substring(prev, lineCommentPosition.from);
|
||||
prev = lineCommentPosition.to;
|
||||
}
|
||||
newQuery = newQuery + query.substring(prev);
|
||||
return newQuery;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user