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/',