Skip to content

Commit 286d44e

Browse files
imyllerjasnell
authored andcommitted
url: fix inconsistent port in url.resolveObject
This commit fixes bug where url.resolveObject returns conflicting host and port values. Fixes: #8213 PR-URL: #8214 Reviewed-By: James M Snell <[email protected]>
1 parent b4ea3a0 commit 286d44e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/url.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ Url.prototype.resolveObject = function(relative) {
781781
// it's absolute.
782782
if (relative.host || relative.host === '') {
783783
result.host = relative.host;
784+
result.port = relative.port;
784785
result.auth = null;
785786
}
786787
if (relative.hostname || relative.hostname === '') {

test/parallel/test-url.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,11 @@ var relativeTests2 = [
15701570
'http://asdf:[email protected]',
15711571
'http://diff:[email protected]/'],
15721572

1573+
// changing port
1574+
['https://example.com:81/',
1575+
'https://example.com:82/',
1576+
'https://example.com:81/'],
1577+
15731578
// https://github.com/nodejs/node/issues/1435
15741579
['https://another.host.com/',
15751580
'https://user:[email protected]/',

0 commit comments

Comments
 (0)