fix(templating): fixed detection of nested template variables, fixes #5103

This commit is contained in:
Torkel Ödegaard 2016-05-20 09:58:07 +02:00
parent df0ddc0b50
commit 2416ee04c8
2 changed files with 10 additions and 2 deletions

View File

@ -97,8 +97,11 @@ function (angular, _) {
if (!str) {
return false;
}
var match = this._regex.exec(str);
return match && (match[1] === variableName || match[2] === variableName);
variableName = regexEscape(variableName);
var findVarRegex = new RegExp('\\$(' + variableName + ')[\\W|$]|\\[\\[(' + variableName + ')\\]\\]', 'g');
var match = findVarRegex.exec(str);
return match !== null;
};
this.highlightVariablesAsHtml = function(str) {

View File

@ -200,6 +200,11 @@ define([
expect(contains).to.be(true);
});
it('should find it when part of segment', function() {
var contains = _templateSrv.containsVariable('metrics.$env.$group-*', 'group');
expect(contains).to.be(true);
});
});
describe('updateTemplateData with simple value', function() {