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 <[email protected]>
1 parent d863619 commit 14c7dcb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/url.js

+1
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

+5
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,11 @@ var relativeTests2 = [
15401540
'http://asdf:[email protected]',
15411541
'http://diff:[email protected]/'],
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:[email protected]/',

0 commit comments

Comments
 (0)