From 89822acf38d5c128436ae93541e069dab7326b2e Mon Sep 17 00:00:00 2001 From: Denis Doria Date: Tue, 11 Jul 2017 23:54:32 -0500 Subject: [PATCH] More precise detection for self reference variable on templates (#8814) This should close the bug #8773 --- public/app/features/templating/editor_ctrl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/templating/editor_ctrl.ts b/public/app/features/templating/editor_ctrl.ts index b2ca08f2395..97274cb30d0 100644 --- a/public/app/features/templating/editor_ctrl.ts +++ b/public/app/features/templating/editor_ctrl.ts @@ -77,7 +77,7 @@ export class VariableEditorCtrl { return false; } - if ($scope.current.type === 'query' && $scope.current.query.match(new RegExp('\\$' + $scope.current.name))) { + if ($scope.current.type === 'query' && $scope.current.query.match(new RegExp('\\$' + $scope.current.name + '(/| |$)'))) { $scope.appEvent('alert-warning', ['Validation', 'Query cannot contain a reference to itself. Variable: $' + $scope.current.name]); return false; }