mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
Variables: Fixes maximum call stack bug for empty value (#25503)
This commit is contained in:
parent
cf2343fac8
commit
bd44d973cd
@ -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…
Reference in New Issue
Block a user