Skip to content

Commit

Permalink
Merge pull request #1743 from simov/fix-default-options
Browse files Browse the repository at this point in the history
Fix options not being initialized in defaults method
  • Loading branch information
simov committed Aug 21, 2015
2 parents 58e8f53 + 39e2bb2 commit f1537d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -105,6 +105,8 @@ function wrapRequestMethod (method, options, requester, verb) {
request.defaults = function (options, requester) {
var self = this

options = options || {}

if (typeof options === 'function') {
requester = options
options = {}
Expand Down
8 changes: 8 additions & 0 deletions tests/test-defaults.js
Expand Up @@ -312,6 +312,14 @@ tape('invoke convenience method from defaults', function(t) {
})
})

tape('defaults without options', function(t) {
var d = request.defaults()
d.get(s.url + '/', {json: true}, function (e, r, b) {
t.equal(r.statusCode, 200)
t.end()
})
})

tape('cleanup', function(t) {
s.close(function() {
t.end()
Expand Down

0 comments on commit f1537d6

Please sign in to comment.