Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2c288a6

Browse files
imyllerrvagg
authored andcommittedOct 18, 2016
url: fix inconsistent port in url.resolveObject
This commit fixes bug where url.resolveObject returns conflicting host and port values. Fixes: #8213 Ref: #8872 PR-URL: #8214 Reviewed-By: James M Snell <[email protected]>
1 parent 423ff6f commit 2c288a6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
 

‎lib/url.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,10 @@ Url.prototype.resolveObject = function(relative) {
564564

565565
if (isRelAbs) {
566566
// it's absolute.
567-
result.host = (relative.host || relative.host === '') ?
568-
relative.host : result.host;
567+
if (relative.host || relative.host === '') {
568+
result.host = relative.host;
569+
result.port = relative.port;
570+
}
569571
result.hostname = (relative.hostname || relative.hostname === '') ?
570572
relative.hostname : result.hostname;
571573
result.search = relative.search;

‎test/parallel/test-url.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,13 @@ var relativeTests2 = [
15131513
//changeing auth
15141514
['http://diff:auth@www.example.com',
15151515
'http://asdf:qwer@www.example.com',
1516-
'http://diff:auth@www.example.com/']
1516+
'http://diff:auth@www.example.com/'],
1517+
1518+
// changing port
1519+
['https://example.com:81/',
1520+
'https://example.com:82/',
1521+
'https://example.com:81/']
1522+
15171523
];
15181524
relativeTests2.forEach(function(relativeTest) {
15191525
const a = url.resolve(relativeTest[1], relativeTest[0]);

0 commit comments

Comments
 (0)
Please sign in to comment.