mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix autocomplete situations with multiple escaped quotes (#65520)
fix situations with multiple quotes
This commit is contained in:
parent
5c138e16d7
commit
b01194f81e
@ -154,6 +154,12 @@ describe('situation', () => {
|
||||
type: 'IN_LABEL_SELECTOR_NO_LABEL_NAME',
|
||||
otherLabels: [{ name: 'one', value: 'val\\"1', op: '=' }],
|
||||
});
|
||||
|
||||
// double-quoted label-values with escape and multiple quotes
|
||||
assertSituation('{one="val\\"1\\"",^}', {
|
||||
type: 'IN_LABEL_SELECTOR_NO_LABEL_NAME',
|
||||
otherLabels: [{ name: 'one', value: 'val"1"', op: '=' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('identifies AFTER_UNWRAP autocomplete situations', () => {
|
||||
|
@ -63,14 +63,14 @@ function parseStringLiteral(text: string): string {
|
||||
if (text.startsWith('"') && text.endsWith('"')) {
|
||||
// NOTE: this is not 100% perfect, we only unescape the double-quote,
|
||||
// there might be other characters too
|
||||
return inside.replace(/\\"/, '"');
|
||||
return inside.replace(/\\"/gm, '"');
|
||||
}
|
||||
|
||||
// Single quotes
|
||||
if (text.startsWith("'") && text.endsWith("'")) {
|
||||
// NOTE: this is not 100% perfect, we only unescape the single-quote,
|
||||
// there might be other characters too
|
||||
return inside.replace(/\\'/, "'");
|
||||
return inside.replace(/\\'/gm, "'");
|
||||
}
|
||||
|
||||
// Backticks
|
||||
|
Loading…
Reference in New Issue
Block a user