From 14c7dcbbcd89e2ff47c4ef52b81ea5f75b24b4eb Mon Sep 17 00:00:00 2001 From: Ilkka Myller Date: Sun, 21 Aug 2016 23:23:31 +0300 Subject: [PATCH] url: fix inconsistent port in url.resolveObject This commit fixes bug where url.resolveObject returns conflicting host and port values. Fixes: https://github.com/nodejs/node/issues/8213 PR-URL: https://github.com/nodejs/node/pull/8214 Reviewed-By: James M Snell --- lib/url.js | 1 + test/parallel/test-url.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/url.js b/lib/url.js index 4a2a879bf3..cdfe122134 100644 --- a/lib/url.js +++ b/lib/url.js @@ -776,6 +776,7 @@ Url.prototype.resolveObject = function(relative) { // it's absolute. if (relative.host || relative.host === '') { result.host = relative.host; + result.port = relative.port; result.auth = null; } if (relative.hostname || relative.hostname === '') { diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index c5933b9c67..6e0ab8be98 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -1540,6 +1540,11 @@ var relativeTests2 = [ 'http://asdf:qwer@www.example.com', 'http://diff:auth@www.example.com/'], + // changing port + ['https://example.com:81/', + 'https://example.com:82/', + 'https://example.com:81/'], + // https://github.com/nodejs/node/issues/1435 ['https://another.host.com/', 'https://user:password@example.org/',