Skip to content

Commit

Permalink
fix: validate opts
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jul 19, 2021
1 parent 5172fd9 commit ad2a490
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,10 @@ class Client extends Dispatcher {
}

try {
const { maxRedirections = this[kMaxRedirections] } = opts
if (maxRedirections != null) {
handler = new RedirectHandler(this, maxRedirections, opts, handler)
if (!opts || typeof opts !== 'object') {
throw new InvalidArgumentError('opts must be a object.')
}

const request = new Request(opts, handler)

if (this[kDestroyed]) {
throw new ClientDestroyedError()
}
Expand All @@ -263,6 +260,13 @@ class Client extends Dispatcher {
throw new ClientClosedError()
}

const { maxRedirections = this[kMaxRedirections] } = opts
if (maxRedirections != null) {
handler = new RedirectHandler(this, maxRedirections, opts, handler)
}

const request = new Request(opts, handler)

this[kQueue].push(request)
if (this[kResuming]) {
// Do nothing.
Expand Down

0 comments on commit ad2a490

Please sign in to comment.