grafana/data: Deprecate kbn.regexEscape and move to grafana/data (#60869)

grafana/data: Deprecate kbn.regexEscape and move escapeRegex to grafana/data
This commit is contained in:
Dominik Prokop
2023-01-02 05:57:55 -08:00
committed by GitHub
parent 831e7697ae
commit 4446d500a4
5 changed files with 26 additions and 19 deletions

View File

@@ -1,8 +1,7 @@
import { map, find, filter, indexOf } from 'lodash';
import { ScopedVars } from '@grafana/data';
import { escapeRegex, ScopedVars } from '@grafana/data';
import { TemplateSrv } from '@grafana/runtime';
import kbn from 'app/core/utils/kbn';
import queryPart from './query_part';
import { InfluxQuery, InfluxQueryTag } from './types';
@@ -201,10 +200,10 @@ export default class InfluxQueryModel {
}
if (typeof value === 'string') {
return kbn.regexEscape(value);
return escapeRegex(value);
}
const escapedValues = map(value, kbn.regexEscape);
const escapedValues = map(value, escapeRegex);
return '(' + escapedValues.join('|') + ')';
}

View File

@@ -1,6 +1,6 @@
import { reduce } from 'lodash';
import kbn from 'app/core/utils/kbn';
import { escapeRegex } from '@grafana/data';
function renderTagCondition(tag: { operator: any; value: string; condition: any; key: string }, index: number) {
// FIXME: merge this function with influx_query_model/renderTagCondition
@@ -48,7 +48,7 @@ export class InfluxQueryBuilder {
query = 'SHOW MEASUREMENTS';
if (withMeasurementFilter) {
// we do a case-insensitive regex-based lookup
query += ' WITH MEASUREMENT =~ /(?i)' + kbn.regexEscape(withMeasurementFilter) + '/';
query += ' WITH MEASUREMENT =~ /(?i)' + escapeRegex(withMeasurementFilter) + '/';
}
} else if (type === 'FIELDS') {
measurement = this.target.measurement;