Skip to content

Commit

Permalink
Fix: Query strings fails for falsifying booleans and numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauri Svan committed Jul 6, 2016
1 parent 596b46c commit acb3046
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "request-promise-lite",
"version": "0.5.1",
"version": "0.5.2",
"description": "Lightweight, promiseful http/https request client",
"main": "lib/index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class Request {
const unparsedValues = map[key];
let values;

if (!unparsedValues) {
if (typeof unparsedValues === 'undefined') {
// TODO Check this - can we send keys that have values? request module thinks 'no'
//return key;
return '';
Expand Down
17 changes: 17 additions & 0 deletions test/RequestSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ describe('Request - test against httpbin.org', () => {
});
});

it('Supports booleans, strings, and numbers in query object', () => {
url = 'https://httpbin.org/get';
const qs = {
text: 'test text',
number: -1,
boolean: false,
};
request = new Request('GET', url, { json: true, qs: qs });

return request.run()
.then(response => {
expect(response.args.text).to.equal('test text');
expect(response.args.number).to.equal('-1');
expect(response.args.boolean).to.equal('false');
});
});

it('Accepts custom headers', () => {
url = 'https://httpbin.org/headers';
headers = {
Expand Down

0 comments on commit acb3046

Please sign in to comment.