#337: properly serialize null values in request.buildQuery

This commit is contained in:
SleepWalker 2017-06-12 22:02:15 +03:00
parent 59000926ab
commit 41661dbea5
2 changed files with 3 additions and 2 deletions

View File

@ -114,7 +114,7 @@ function doFetch(url, options = {}) {
* @return {string} * @return {string}
*/ */
function convertQueryValue(value) { function convertQueryValue(value) {
if (typeof value === 'undefined') { if (typeof value === 'undefined' || value === null) {
return ''; return '';
} }

View File

@ -57,12 +57,13 @@ describe('services/request', () => {
it('should build query', () => { it('should build query', () => {
const data = { const data = {
notSet: undefined, notSet: undefined,
notSet2: null,
numeric: 1, numeric: 1,
complexString: 'sdfgs sdfg ', complexString: 'sdfgs sdfg ',
positive: true, positive: true,
negative: false negative: false
}; };
const expectedQs = 'notSet=&numeric=1&complexString=sdfgs%20sdfg%20&positive=1&negative=0'; const expectedQs = 'notSet=&notSet2=&numeric=1&complexString=sdfgs%20sdfg%20&positive=1&negative=0';
expect(request.buildQuery(data), 'to equal', expectedQs); expect(request.buildQuery(data), 'to equal', expectedQs);
}); });