Variables: Fixes maximum call stack bug for empty value (#25503)

pull/25606/head
Hugo Häggmark 6 years ago committed by GitHub
parent cf2343fac8
commit bd44d973cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      public/app/core/services/bridge_srv.test.ts
  2. 2
      public/app/core/services/bridge_srv.ts

@ -12,4 +12,32 @@ describe('when checking template variables', () => {
expect(findTemplateVarChanges(b, a)).toEqual({ 'var-xyz': 'hello' });
expect(findTemplateVarChanges(a, b)).toEqual({ 'var-xyz': '' });
});
it('then should ignore equal values', () => {
const a: UrlQueryMap = {
'var-xyz': 'hello',
bbb: 'ignore me',
};
const b: UrlQueryMap = {
'var-xyz': 'hello',
aaa: 'ignore me',
};
expect(findTemplateVarChanges(b, a)).toBeUndefined();
expect(findTemplateVarChanges(a, b)).toBeUndefined();
});
it('then should ignore equal values with empty values', () => {
const a: UrlQueryMap = {
'var-xyz': '',
bbb: 'ignore me',
};
const b: UrlQueryMap = {
'var-xyz': '',
aaa: 'ignore me',
};
expect(findTemplateVarChanges(b, a)).toBeUndefined();
expect(findTemplateVarChanges(a, b)).toBeUndefined();
});
});

@ -124,7 +124,7 @@ export function findTemplateVarChanges(query: UrlQueryMap, old: UrlQueryMap): Ur
if (!key.startsWith('var-')) {
continue;
}
if (!query[key]) {
if (!query.hasOwnProperty(key)) {
changes[key] = ''; // removed
count++;
}

Loading…
Cancel
Save