mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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:
1 parent
eec5d02266
commit
6ae7af0fa3
2 files changed
+5
-2
No files matched your search
+2
-2
@@ -775,13 +775,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;
|
||||
|
||||
@@ -1571,6 +1571,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]);
|
||||
|
||||
Reference in new issue
Block a user