mqtt 5.6.2 → 5.7.0

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 CHANGED
@@ -12634,7 +12634,7 @@ var mqtt = (() => {
12634
12634
  // package-json:../../package.json
12635
12635
  var require_package = __commonJS({
12636
12636
  "package-json:../../package.json"(exports5, module) {
12637
- module.exports = { version: "5.6.2" };
12637
+ module.exports = { version: "5.7.0" };
12638
12638
  }
12639
12639
  });
12640
12640
 
@@ -21395,6 +21395,7 @@ var mqtt = (() => {
21395
21395
  }
21396
21396
  }
21397
21397
  function connect(brokerUrl, opts) {
21398
+ var _a, _b, _c;
21398
21399
  debug("connecting to an MQTT broker...");
21399
21400
  if (typeof brokerUrl === "object" && !opts) {
21400
21401
  opts = brokerUrl;
@@ -21402,21 +21403,27 @@ var mqtt = (() => {
21402
21403
  }
21403
21404
  opts = opts || {};
21404
21405
  if (brokerUrl && typeof brokerUrl === "string") {
21405
- const parsed = url_1.default.parse(brokerUrl, true);
21406
- if (parsed.port != null) {
21407
- parsed.port = Number(parsed.port);
21408
- }
21409
- opts = Object.assign({
21410
- port: parsed.port,
21411
- host: parsed.hostname,
21412
- protocol: parsed.protocol,
21413
- query: parsed.query,
21414
- auth: parsed.auth
21415
- }, opts);
21416
- if (opts.protocol === null) {
21406
+ const parsedUrl = url_1.default.parse(brokerUrl, true);
21407
+ const parsedOptions = {};
21408
+ if (parsedUrl.port != null) {
21409
+ parsedOptions.port = Number(parsedUrl.port);
21410
+ }
21411
+ parsedOptions.host = parsedUrl.hostname;
21412
+ parsedOptions.query = parsedUrl.query;
21413
+ parsedOptions.auth = parsedUrl.auth;
21414
+ parsedOptions.protocol = parsedUrl.protocol;
21415
+ parsedOptions.path = parsedUrl.path;
21416
+ parsedOptions.protocol = (_a = parsedOptions.protocol) === null || _a === void 0 ? void 0 : _a.replace(/:$/, "");
21417
+ opts = Object.assign(Object.assign({}, parsedOptions), opts);
21418
+ if (!opts.protocol) {
21417
21419
  throw new Error("Missing protocol");
21418
21420
  }
21419
- opts.protocol = opts.protocol.replace(/:$/, "");
21421
+ }
21422
+ opts.unixSocket = opts.unixSocket || ((_b = opts.protocol) === null || _b === void 0 ? void 0 : _b.includes("+unix"));
21423
+ if (opts.unixSocket) {
21424
+ opts.protocol = opts.protocol.replace("+unix", "");
21425
+ } else if (!((_c = opts.protocol) === null || _c === void 0 ? void 0 : _c.startsWith("ws"))) {
21426
+ delete opts.path;
21420
21427
  }
21421
21428
  parseAuthOptions(opts);
21422
21429
  if (opts.query && typeof opts.query.clientId === "string") {