Loki: Fix autocomplete situations with multiple escaped quotes (#65520)

fix situations with multiple quotes
new-panel-creation-experience-poc^2
Sven Grossmann 2 years ago committed by GitHub
parent 5c138e16d7
commit b01194f81e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.test.ts
  2. 4
      public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.ts

@ -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…
Cancel
Save