Skip to content

Commit

Permalink
Merge pull request #15 from ovh/fix_null_like_params
Browse files Browse the repository at this point in the history
fix(ovh): disable deletion of 0 or empty string params
  • Loading branch information
bnjjj authored Aug 10, 2016
2 parents 835a178 + 12d6d1f commit b906fd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/ovh.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var Ovh = function () {
return this.addApi(apiPath, api, apis);
}

if (!apis[path]) {
if (apis[path] == null) {
apis[path] = { _path: apis._path + '/' + path };
}

Expand Down Expand Up @@ -279,7 +279,7 @@ var Ovh = function () {
value: function request(httpMethod, path, params, callback, refer) {
var _this2 = this;

if (!callback) {
if (callback == null) {
callback = params;
}

Expand Down Expand Up @@ -345,7 +345,7 @@ var Ovh = function () {

// Remove undefined values
for (var k in params) {
if (params.hasOwnProperty(k) && !params[k]) {
if (params.hasOwnProperty(k) && params[k] == null) {
delete params[k];
}
}
Expand Down Expand Up @@ -424,7 +424,7 @@ var Ovh = function () {
if (typeof this.timeout === 'number') {
req.on('socket', function (socket) {
socket.setTimeout(_this2.timeout);
if (!socket._events.timeout) {
if (socket._events.timeout != null) {
socket.on('timeout', function () {
return req.abort();
});
Expand Down
8 changes: 4 additions & 4 deletions lib/ovh.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Ovh {
return this.addApi(apiPath, api, apis);
}

if (!apis[path]) {
if (apis[path] == null) {
apis[path] = { _path: apis._path + '/' + path };
}

Expand Down Expand Up @@ -271,7 +271,7 @@ class Ovh {
* @param {Object} refer: The parent proxied object
*/
request(httpMethod, path, params, callback, refer) {
if (!callback) {
if (callback == null) {
callback = params;
}

Expand Down Expand Up @@ -337,7 +337,7 @@ class Ovh {

// Remove undefined values
for (let k in params) {
if (params.hasOwnProperty(k) && !params[k]) {
if (params.hasOwnProperty(k) && params[k] == null) {
delete params[k];
}
}
Expand Down Expand Up @@ -428,7 +428,7 @@ class Ovh {
if (typeof(this.timeout) === 'number') {
req.on('socket', (socket) => {
socket.setTimeout(this.timeout);
if (!socket._events.timeout) {
if (socket._events.timeout != null) {
socket.on('timeout', () => req.abort());
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ovh",
"version": "2.0.0",
"version": "2.0.1",
"description": "Official Node.js wrapper for the OVH APIs",
"homepage": "http://ovh.github.io/node-ovh",
"author": "Vincent Giersch <vincent.giersch@ovh.net>",
Expand Down

0 comments on commit b906fd7

Please sign in to comment.