mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch '11780_wrong_repexp_in_series' of https://github.com/SamuelToh/grafana into SamuelToh-11780_wrong_repexp_in_series
This commit is contained in:
commit
01eb5fade3
15
public/app/core/specs/kbn.test.ts
Normal file
15
public/app/core/specs/kbn.test.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import kbn from '../utils/kbn';
|
||||
|
||||
describe('stringToJsRegex', () => {
|
||||
it('should parse the valid regex value', () => {
|
||||
const output = kbn.stringToJsRegex("/validRegexp/");
|
||||
expect(output).toBeInstanceOf(RegExp);
|
||||
});
|
||||
|
||||
it('should throw error on invalid regex value', () => {
|
||||
const input = "/etc/hostname";
|
||||
expect(() => {
|
||||
kbn.stringToJsRegex(input);
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
@ -234,6 +234,11 @@ kbn.stringToJsRegex = str => {
|
||||
}
|
||||
|
||||
const match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$'));
|
||||
|
||||
if (!match) {
|
||||
throw new Error(`'${str}' is not a valid regular expression.`);
|
||||
}
|
||||
|
||||
return new RegExp(match[1], match[2]);
|
||||
};
|
||||
|
||||
|
@ -235,7 +235,11 @@ class GraphCtrl extends MetricsPanelCtrl {
|
||||
}
|
||||
|
||||
for (const series of this.seriesList) {
|
||||
series.applySeriesOverrides(this.panel.seriesOverrides);
|
||||
try {
|
||||
series.applySeriesOverrides(this.panel.seriesOverrides);
|
||||
} catch (e) {
|
||||
this.publishAppEvent('alert-error', [e.message]);
|
||||
}
|
||||
|
||||
if (series.unit) {
|
||||
this.panel.yaxes[series.yaxis - 1].format = series.unit;
|
||||
|
Loading…
Reference in New Issue
Block a user