File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,16 @@ function connect(
80
80
parsed . port = Number ( parsed . port )
81
81
}
82
82
83
- opts = { ...parsed , ...opts } as IClientOptions
83
+ opts = {
84
+ ...{
85
+ port : parsed . port ,
86
+ host : parsed . hostname ,
87
+ protocol : parsed . protocol ,
88
+ query : parsed . query ,
89
+ auth : parsed . auth ,
90
+ } ,
91
+ ...opts ,
92
+ } as IClientOptions
84
93
85
94
if ( opts . protocol === null ) {
86
95
throw new Error ( 'Missing protocol' )
Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ describe('mqtt', () => {
34
34
c . end ( ( err ) => done ( err ) )
35
35
} )
36
36
37
+ it ( 'should not set `path` when parsing url' , function _test ( t , done ) {
38
+ const c = mqtt . connect ( 'mqtt://[::1]' )
39
+
40
+ c . should . be . instanceOf ( mqtt . MqttClient )
41
+ c . options . should . not . have . property ( 'path' )
42
+ c . options . should . have . property ( 'host' , '::1' )
43
+ c . end ( ( err ) => done ( err ) )
44
+ } )
45
+
37
46
it ( 'should return an MqttClient with username and password options set' , function _test ( t , done ) {
38
47
const c = mqtt . connect ( 'mqtt://user@localhost:1883' )
39
48
You can’t perform that action at this time.
0 commit comments