Browse Source

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>
v6.x
Ilkka Myller 9 years ago
committed by Evan Lucas
parent
commit
14c7dcbbcd
  1. 1
      lib/url.js
  2. 5
      test/parallel/test-url.js

1
lib/url.js

@ -776,6 +776,7 @@ Url.prototype.resolveObject = function(relative) {
// it's absolute. // it's absolute.
if (relative.host || relative.host === '') { if (relative.host || relative.host === '') {
result.host = relative.host; result.host = relative.host;
result.port = relative.port;
result.auth = null; result.auth = null;
} }
if (relative.hostname || relative.hostname === '') { if (relative.hostname || relative.hostname === '') {

5
test/parallel/test-url.js

@ -1540,6 +1540,11 @@ var relativeTests2 = [
'http://asdf:qwer@www.example.com', 'http://asdf:qwer@www.example.com',
'http://diff:auth@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://github.com/nodejs/node/issues/1435
['https://another.host.com/', ['https://another.host.com/',
'https://user:password@example.org/', 'https://user:password@example.org/',

Loading…
Cancel
Save