diff --git a/lib/url.js b/lib/url.js index 385061b678d..64aa7bc59b3 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 209df0df3e7..613dceca5f6 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/',