Skip to content

Commit 6240565

Browse files
author
Yoseph Maguire
authored
fix(ws): add all parts of object to opts (mqttjs#1194)
this is to make sure that all the options are included in the URL object.
1 parent 2de81e6 commit 6240565

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/connect/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,22 @@ function connect (brokerUrl, opts) {
6262
throw new Error('Missing protocol')
6363
}
6464
var parsed = new URL(brokerUrl)
65+
6566
// the URL object is a bit special, so copy individual
6667
// items to the opts object
67-
opts.hostname = parsed.hostname
68+
opts.hash = parsed.hash
6869
opts.host = parsed.host
69-
opts.protocol = parsed.protocol
70+
opts.hostname = parsed.hostname
71+
opts.href = parsed.href
72+
opts.origin = parsed.origin
73+
opts.pathname = parsed.pathname
7074
opts.port = Number(parsed.port) || null
75+
opts.protocol = parsed.protocol
7176
opts.username = opts.username || parsed.username
7277
opts.password = opts.password || parsed.password
78+
opts.search = parsed.search
7379
opts.searchParams = parsed.searchParams
80+
opts.path = parsed.pathname + parsed.search
7481
opts.protocol = opts.protocol.replace(/:$/, '')
7582
}
7683

0 commit comments

Comments
 (0)