Commit bd44d973 by Hugo Häggmark Committed by GitHub

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

parent cf2343fa
......@@ -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++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment