url: keep auth in url.resolve()
if host matches
Fixes: https://github.com/nodejs/node/issues/8165 PR-URL: https://github.com/nodejs/node/pull/8215 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
09f861f231
commit
51f96dfcfc
@ -780,13 +780,13 @@ Url.prototype.resolveObject = function(relative) {
|
||||
if (isRelAbs) {
|
||||
// it's absolute.
|
||||
if (relative.host || relative.host === '') {
|
||||
if (result.host !== relative.host) result.auth = null;
|
||||
result.host = relative.host;
|
||||
result.port = relative.port;
|
||||
result.auth = null;
|
||||
}
|
||||
if (relative.hostname || relative.hostname === '') {
|
||||
if (result.hostname !== relative.hostname) result.auth = null;
|
||||
result.hostname = relative.hostname;
|
||||
result.auth = null;
|
||||
}
|
||||
result.search = relative.search;
|
||||
result.query = relative.query;
|
||||
|
@ -1588,6 +1588,9 @@ var relativeTests2 = [
|
||||
['mailto:another.host.com',
|
||||
'mailto:user@example.org',
|
||||
'mailto:another.host.com'],
|
||||
['https://example.com/foo',
|
||||
'https://user:password@example.com',
|
||||
'https://user:password@example.com/foo'],
|
||||
];
|
||||
relativeTests2.forEach(function(relativeTest) {
|
||||
const a = url.resolve(relativeTest[1], relativeTest[0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user