mqtt 4.2.5 → 4.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mqtt.js +1513 -58
- package/dist/mqtt.min.js +1 -1
- package/lib/connect/index.js +10 -23
- package/package.json +2 -2
package/lib/connect/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var MqttClient = require('../client')
|
|
4
4
|
var Store = require('../store')
|
|
5
|
+
var url = require('url')
|
|
6
|
+
var xtend = require('xtend')
|
|
5
7
|
var debug = require('debug')('mqttjs')
|
|
6
8
|
|
|
7
9
|
var protocols = {}
|
|
@@ -58,39 +60,24 @@ function connect (brokerUrl, opts) {
|
|
|
58
60
|
opts = opts || {}
|
|
59
61
|
|
|
60
62
|
if (brokerUrl) {
|
|
63
|
+
var parsed = url.parse(brokerUrl, true)
|
|
64
|
+
if (parsed.port != null) {
|
|
65
|
+
parsed.port = Number(parsed.port)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
opts = xtend(parsed, opts)
|
|
69
|
+
|
|
61
70
|
if (opts.protocol === null) {
|
|
62
71
|
throw new Error('Missing protocol')
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// the URL object is a bit special, so copy individual
|
|
67
|
-
// items to the opts object
|
|
68
|
-
opts.hash = parsed.hash
|
|
69
|
-
opts.host = parsed.host
|
|
70
|
-
opts.hostname = parsed.hostname
|
|
71
|
-
opts.href = parsed.href
|
|
72
|
-
opts.origin = parsed.origin
|
|
73
|
-
opts.pathname = parsed.pathname
|
|
74
|
-
opts.port = Number(parsed.port) || null
|
|
75
|
-
opts.protocol = parsed.protocol
|
|
76
|
-
opts.username = opts.username || parsed.username || null
|
|
77
|
-
opts.password = opts.password || parsed.password || null
|
|
78
|
-
opts.search = parsed.search
|
|
79
|
-
opts.searchParams = parsed.searchParams
|
|
80
|
-
opts.path = parsed.pathname + parsed.search
|
|
73
|
+
|
|
81
74
|
opts.protocol = opts.protocol.replace(/:$/, '')
|
|
82
75
|
}
|
|
83
76
|
|
|
84
77
|
// merge in the auth options if supplied
|
|
85
|
-
// legacy support for url.parse objects (now deprecated in node.js)
|
|
86
78
|
parseAuthOptions(opts)
|
|
87
79
|
|
|
88
80
|
// support clientId passed in the query string of the url
|
|
89
|
-
if (opts.searchParams && typeof opts.searchParams.get('clientId') === 'string') {
|
|
90
|
-
opts.clientId = opts.searchParams.get('clientId')
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// legacy support for url.parse objects (now deprecated in node.js)
|
|
94
81
|
if (opts.query && typeof opts.query.clientId === 'string') {
|
|
95
82
|
opts.clientId = opts.query.clientId
|
|
96
83
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mqtt",
|
|
3
3
|
"description": "A library for the MQTT protocol",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.6",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Adam Rudd <adamvrr@gmail.com>",
|
|
7
7
|
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"ci": "npm run tslint && npm run typescript-compile-test && npm run test && codecov"
|
|
36
36
|
},
|
|
37
37
|
"pre-commit": [
|
|
38
|
-
"
|
|
38
|
+
"pretest",
|
|
39
39
|
"tslint"
|
|
40
40
|
],
|
|
41
41
|
"bin": {
|