Skip to content

Commit

Permalink
remove console.log's and make compatible with legacy node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
e-e-e committed Nov 15, 2017
1 parent 1a4a979 commit b25d48e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var needle = require('needle'),

function Request(method, url, params, opts, tries, callback) {
var location = url;
var needleParams = (params && Object.keys(params).length > 0) ? params : undefined
var needleParams = (params && !isEmptyObject(params)) ? params : undefined
return needle.request(method,
url.href,
needleParams,
Expand Down Expand Up @@ -163,4 +163,14 @@ function extend(object, donor) {
return object;
}

function isEmptyObject(obj) {
if (Object.keys) return !Object.keys(obj).length;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
return false;
}
}
return true;
}

module.exports = Request;
3 changes: 1 addition & 2 deletions test/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports.absentQueryString = function (assert) {
osmosis.get(url + '/query')
.find('div')
.set({ content: 'p' })
.data((data) => {
.data(function (data) {
found = true
})
.done(function () {
Expand Down Expand Up @@ -193,7 +193,6 @@ server('/test-test', function (url, req, res) {

server('/query', function (url, req, res) {
if (url.path === '/query?') {
console.log('empty', url)
res.writeHead(404);
res.end();
return;
Expand Down

0 comments on commit b25d48e

Please sign in to comment.