Merge pull request #4368 from simnv/variable-escape

Slash escape regex
This commit is contained in:
Torkel Ödegaard 2016-03-20 11:22:33 +01:00
commit 06468d6f43
2 changed files with 6 additions and 1 deletions

View File

@ -35,7 +35,7 @@ function (angular, _) {
};
function regexEscape(value) {
return value.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
}
function luceneEscape(value) {

View File

@ -135,6 +135,11 @@ define([
expect(result).to.be('test|test2');
});
it('slash should be properly escaped in regex format', function() {
var result = _templateSrv.formatValue('Gi3/14', 'regex');
expect(result).to.be('Gi3\\/14');
});
});
describe('can check if variable exists', function() {