Skip to content

Commit da9eb26

Browse files
fix an issue where a single value wasn't interpolated by double quotes (#445)
1 parent b303e88 commit da9eb26

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* FEATURE: add bars as the default type of visualization for explore mode. Adjust the width of the bars to match the step size. See [#420](https://github.com/VictoriaMetrics/victorialogs-datasource/pull/420).
66

77
* BUGFIX: fix an issue where a warning was displayed when using the regexp operator not with a variable. See [#438](https://github.com/VictoriaMetrics/victorialogs-datasource/pull/438).
8+
* BUGFIX: fix an issue where a single value wasn't interpolated by double quotes. See [#444](https://github.com/VictoriaMetrics/victorialogs-datasource/pull/444).
89

910
## v0.21.4
1011

src/datasource.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('VictoriaLogsDatasource', () => {
4949
});
5050

5151
it('should return a value escaped by stringify for one array element', () => {
52-
expect(ds.interpolateQueryExpr(['arg // for & test " this string ` end test'] as any, customVariable)).toEqual("arg // for & test \" this string ` end test");
52+
expect(ds.interpolateQueryExpr(['arg // for & test " this string ` end test'] as any, customVariable)).toEqual("$_StartMultiVariable_arg // for & test \" this string ` end test_EndMultiVariable");
5353
});
5454
});
5555

src/datasource.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ export class VictoriaLogsDatasource
210210

211211
interpolateQueryExpr(value: any, _variable: any) {
212212
if (typeof value === 'string') {
213-
return value ? JSON.stringify(value) : value;
213+
return value ? `${JSON.stringify(value)}` : value;
214214
}
215215

216216
if (Array.isArray(value)) {
217-
return value.length > 1 ? `$_StartMultiVariable_${value.join("_separator_")}_EndMultiVariable` : value[0] || "";
217+
return value.length > 0 ? `$_StartMultiVariable_${value.join("_separator_")}_EndMultiVariable` : "";
218218
}
219219

220220
return value;
@@ -288,8 +288,8 @@ export class VictoriaLogsDatasource
288288
}
289289

290290
replaceAllOption(queryExpr: string, variableName: string, regExpAllValue: string): string {
291-
queryExpr = queryExpr.replace(`~"$${variableName}"`, `~"${regExpAllValue}"` || '~".*"');
292-
queryExpr = queryExpr.replace(`$${variableName}`, '*');
291+
queryExpr = queryExpr.replaceAll(`~"$${variableName}"`, `~"${regExpAllValue}"` || '~".*"');
292+
queryExpr = queryExpr.replaceAll(`$${variableName}`, '*');
293293
return queryExpr;
294294
}
295295

0 commit comments

Comments
 (0)