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 <jasnell@gmail.com>
This commit is contained in:
Ilkka Myller authored and Evan Lucas committed 2016-08-24 08:37:11 -05:00
1 parent d863619a30
commit 14c7dcbbcd
2 files changed
+6

No files matched your search

+1
View File
@@ -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 === '') {
+5
View File
@@ -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/',