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(
8080 parsed . port = Number ( parsed . port )
8181 }
8282
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
8493
8594 if ( opts . protocol === null ) {
8695 throw new Error ( 'Missing protocol' )
Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ describe('mqtt', () => {
3434 c . end ( ( err ) => done ( err ) )
3535 } )
3636
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+
3746 it ( 'should return an MqttClient with username and password options set' , function _test ( t , done ) {
3847 const c = mqtt . connect ( 'mqtt://user@localhost:1883' )
3948
You can’t perform that action at this time.
0 commit comments