From 286d44e43d179f82a7dde55ed8e67409e21e3013 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 385061b678d89a..64aa7bc59b3c85 100644 --- a/lib/url.js +++ b/lib/url.js @@ -781,6 +781,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 209df0df3e7829..613dceca5f6eb6 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -1570,6 +1570,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/',