We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
url.resolve()
1 parent bd2cee1 commit 1b50b80Copy full SHA for 1b50b80
2 files changed
lib/url.js
@@ -754,6 +754,7 @@ Url.prototype.resolveObject = function(relative) {
754
if (relative.protocol) {
755
relative.hostname = null;
756
relative.port = null;
757
+ result.auth = null;
758
if (relative.host) {
759
if (relPath[0] === '') relPath[0] = relative.host;
760
else relPath.unshift(relative.host);
@@ -765,10 +766,14 @@ Url.prototype.resolveObject = function(relative) {
765
766
767
if (isRelAbs) {
768
// it's absolute.
- result.host = (relative.host || relative.host === '') ?
769
- relative.host : result.host;
770
- result.hostname = (relative.hostname || relative.hostname === '') ?
771
- relative.hostname : result.hostname;
+ if (relative.host || relative.host === '') {
+ result.host = relative.host;
772
+ }
773
+ if (relative.hostname || relative.hostname === '') {
774
+ result.hostname = relative.hostname;
775
776
777
result.search = relative.search;
778
result.query = relative.query;
779
srcPath = relPath;
test/parallel/test-url.js
@@ -1538,7 +1538,21 @@ var relativeTests2 = [
1538
//changeing auth
1539
['http://diff:auth@www.example.com',
1540
'http://asdf:qwer@www.example.com',
1541
- 'http://diff:auth@www.example.com/']
+ 'http://diff:auth@www.example.com/'],
1542
+
1543
+ // https://github.com/nodejs/node/issues/1435
1544
+ ['https://another.host.com/',
1545
+ 'https://user:password@example.org/',
1546
+ 'https://another.host.com/'],
1547
+ ['//another.host.com/',
1548
1549
1550
+ ['http://another.host.com/',
1551
1552
+ 'http://another.host.com/'],
1553
+ ['mailto:another.host.com',
1554
+ 'mailto:user@example.org',
1555
+ 'mailto:another.host.com'],
1556
];
1557
relativeTests2.forEach(function(relativeTest) {
1558
const a = url.resolve(relativeTest[1], relativeTest[0]);
0 commit comments