Skip to content

Commit 0daadc9

Browse files
committed
fix(templating): fixed issue with detecting data source variable in other template variable definition, fixes grafana#5165
1 parent 8c2b6b5 commit 0daadc9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

public/app/features/templating/templateSrv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function (angular, _) {
103103
}
104104

105105
variableName = regexEscape(variableName);
106-
var findVarRegex = new RegExp('\\$(' + variableName + ')[\\W|$]|\\[\\[(' + variableName + ')\\]\\]', 'g');
106+
var findVarRegex = new RegExp('\\$(' + variableName + ')(?:\\W|$)|\\[\\[(' + variableName + ')\\]\\]', 'g');
107107
var match = findVarRegex.exec(str);
108108
return match !== null;
109109
};

public/test/specs/templateSrv-specs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ define([
205205
expect(contains).to.be(true);
206206
});
207207

208+
it('should find it its the only thing', function() {
209+
var contains = _templateSrv.containsVariable('$env', 'env');
210+
expect(contains).to.be(true);
211+
});
208212
});
209213

210214
describe('updateTemplateData with simple value', function() {

0 commit comments

Comments
 (0)