mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
Fix url util converting false
into true
(#37402)
A value of key-value pair is stripped for boolean values. While this is ok for `true`, it kind of inverts `false`
This commit is contained in:
parent
c6356c5bba
commit
9900f2ed48
@ -22,6 +22,14 @@ describe('toUrlParams', () => {
|
||||
});
|
||||
expect(url).toBe('server=:@');
|
||||
});
|
||||
|
||||
it('should keep booleans', () => {
|
||||
const url = urlUtil.toUrlParams({
|
||||
bool1: true,
|
||||
bool2: false,
|
||||
});
|
||||
expect(url).toBe('bool1&bool2=false');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseKeyValue', () => {
|
||||
|
@ -48,7 +48,8 @@ function toUrlParams(a: any) {
|
||||
if (typeof v !== 'boolean') {
|
||||
s[s.length] = encodeURIComponentAsAngularJS(k, true) + '=' + encodeURIComponentAsAngularJS(v, true);
|
||||
} else {
|
||||
s[s.length] = encodeURIComponentAsAngularJS(k, true);
|
||||
const valueQueryPart = v ? '' : '=' + encodeURIComponentAsAngularJS('false', true);
|
||||
s[s.length] = encodeURIComponentAsAngularJS(k, true) + valueQueryPart;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user