From f378fe6db4385f3655cc5bc77e41017cfa3a0b6c Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Mon, 10 Dec 2018 06:33:39 -0800 Subject: [PATCH] Fix for #241 Signed-off-by: Derek Collison --- lib/nats.js | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/nats.js b/lib/nats.js index 5bb3cfed..fde58d29 100644 --- a/lib/nats.js +++ b/lib/nats.js @@ -31,7 +31,7 @@ var net = require('net'), /** * Constants */ -var VERSION = '1.2.0', +var VERSION = '1.2.1', DEFAULT_PORT = 4222, DEFAULT_PRE = 'nats://localhost:', @@ -369,16 +369,16 @@ Client.prototype.parseOptions = function(opts) { } }; -function sanitizeUrl(url) { - if ((/^.*:\/\/.*/).exec(url) === null) { - // Does not have a scheme. - url = 'nats://' + url; - } - var u = new URL(url); +function sanitizeUrl(urlstr) { + if ((/^.*:\/\/.*/).exec(urlstr) === null) { + // Does not have a scheme. + url = 'nats://' + url; + } + var u = url.parse(urlstr); if (u.port === '') { - u.port = DEFAULT_PORT; + u.port = DEFAULT_PORT.toString(); } - return u.toString(); + return url.format(u); } /** diff --git a/package.json b/package.json index 11f1e93b..30126102 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nats", - "version": "1.2.0", + "version": "1.2.1", "description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", "keywords": [ "nats",