File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ function connect (brokerUrl, opts) {
58
58
opts = opts || { }
59
59
60
60
if ( brokerUrl ) {
61
+ if ( opts . protocol === null ) {
62
+ throw new Error ( 'Missing protocol' )
63
+ }
61
64
var parsed = new URL ( brokerUrl )
62
65
// the URL object is a bit special, so copy individual
63
66
// items to the opts object
@@ -68,10 +71,6 @@ function connect (brokerUrl, opts) {
68
71
opts . username = parsed . username
69
72
opts . password = parsed . password
70
73
opts . searchParams = parsed . searchParams
71
-
72
- if ( opts . protocol === null ) {
73
- throw new Error ( 'Missing protocol' )
74
- }
75
74
opts . protocol = opts . protocol . replace ( / : $ / , '' )
76
75
}
77
76
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ describe('mqtt', function () {
18
18
( function ( ) {
19
19
var c = mqtt . connect ( 'foo.bar.com' )
20
20
c . end ( )
21
- } ) . should . throw ( 'Missing protocol ' )
21
+ } ) . should . throw ( 'Invalid URL: foo.bar.com ' )
22
22
} )
23
23
24
24
it ( 'should throw an error when called with no protocol specified - with options' , function ( ) {
You can’t perform that action at this time.
0 commit comments