Skip to content

Commit 14c7dcb

Browse files
imyllerevanlucas
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 <jasnell@gmail.com>
1 parent d863619 commit 14c7dcb

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
@@ -776,6 +776,7 @@ Url.prototype.resolveObject = function(relative) {
776776
// it's absolute.
777777
if (relative.host || relative.host === '') {
778778
result.host = relative.host;
779+
result.port = relative.port;
779780
result.auth = null;
780781
}
781782
if (relative.hostname || relative.hostname === '') {

test/parallel/test-url.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,11 @@ var relativeTests2 = [
15401540
'http://asdf:qwer@www.example.com',
15411541
'http://diff:auth@www.example.com/'],
15421542

1543+
// changing port
1544+
['https://example.com:81/',
1545+
'https://example.com:82/',
1546+
'https://example.com:81/'],
1547+
15431548
// https://github.com/nodejs/node/issues/1435
15441549
['https://another.host.com/',
15451550
'https://user:password@example.org/',

0 commit comments

Comments
 (0)