Skip to content

Commit

Permalink
fix(ws): add all parts of object to opts (#1194)
Browse files Browse the repository at this point in the history
this is to make sure that all the options are included in the URL object.
  • Loading branch information
Yoseph Maguire committed Oct 29, 2020
1 parent 2de81e6 commit 6240565
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/connect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,22 @@ function connect (brokerUrl, opts) {
throw new Error('Missing protocol')
}
var parsed = new URL(brokerUrl)

// the URL object is a bit special, so copy individual
// items to the opts object
opts.hostname = parsed.hostname
opts.hash = parsed.hash
opts.host = parsed.host
opts.protocol = parsed.protocol
opts.hostname = parsed.hostname
opts.href = parsed.href
opts.origin = parsed.origin
opts.pathname = parsed.pathname
opts.port = Number(parsed.port) || null
opts.protocol = parsed.protocol
opts.username = opts.username || parsed.username
opts.password = opts.password || parsed.password
opts.search = parsed.search
opts.searchParams = parsed.searchParams
opts.path = parsed.pathname + parsed.search
opts.protocol = opts.protocol.replace(/:$/, '')
}

Expand Down

0 comments on commit 6240565

Please sign in to comment.