mqtt 4.2.2 → 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.
@@ -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,32 +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
- var parsed = new URL(brokerUrl)
65
- // the URL object is a bit special, so copy individual
66
- // items to the opts object
67
- opts.hostname = parsed.hostname
68
- opts.host = parsed.host
69
- opts.protocol = parsed.protocol
70
- opts.port = Number(parsed.port) || null
71
- opts.username = parsed.username
72
- opts.password = parsed.password
73
- opts.searchParams = parsed.searchParams
73
+
74
74
  opts.protocol = opts.protocol.replace(/:$/, '')
75
75
  }
76
76
 
77
77
  // merge in the auth options if supplied
78
- // legacy support for url.parse objects (now deprecated in node.js)
79
78
  parseAuthOptions(opts)
80
79
 
81
80
  // support clientId passed in the query string of the url
82
- if (opts.searchParams && typeof opts.searchParams.get('clientId') === 'string') {
83
- opts.clientId = opts.searchParams.get('clientId')
84
- }
85
-
86
- // legacy support for url.parse objects (now deprecated in node.js)
87
81
  if (opts.query && typeof opts.query.clientId === 'string') {
88
82
  opts.clientId = opts.query.clientId
89
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.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
- "test",
38
+ "pretest",
39
39
  "tslint"
40
40
  ],
41
41
  "bin": {
@@ -68,13 +68,13 @@
68
68
  "help-me": "^1.0.1",
69
69
  "inherits": "^2.0.3",
70
70
  "minimist": "^1.2.5",
71
- "mqtt-packet": "^6.3.2",
71
+ "mqtt-packet": "^6.6.0",
72
72
  "pump": "^3.0.0",
73
73
  "readable-stream": "^3.6.0",
74
74
  "reinterval": "^1.1.0",
75
75
  "split2": "^3.1.0",
76
76
  "ws": "^7.3.1",
77
- "xtend": "^4.0.1"
77
+ "xtend": "^4.0.2"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "^10.0.0",