url: fix off-by-one error with parse()

Fixes: https://github.com/nodejs/node/issues/5393
PR-URL: https://github.com/nodejs/node/pull/5394
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Evan Lucas <evanlucas@me.com>
This commit is contained in:
Brian White authored and Rod Vagg committed 2016-02-28 12:41:51 +11:00
1 parent 30cec18eeb
commit dfe45f13e7
2 files changed
+16 -1

No files matched your search

+1 -1
View File
@@ -413,7 +413,7 @@ function validateHostname(self, rest, hostname) {
}
// Invalid host character
self.hostname = hostname.slice(0, i);
if (i < hostname.length - 1)
if (i < hostname.length)
return '/' + hostname.slice(i) + rest;
break;
}
+15
View File
@@ -851,6 +851,21 @@ var parseTests = {
pathname: '/:npm/npm',
path: '/:npm/npm',
href: 'git+ssh://git@github.com/:npm/npm'
},
'https://*': {
protocol: 'https:',
slashes: true,
auth: null,
host: '',
port: null,
hostname: '',
hash: null,
search: null,
query: null,
pathname: '/*',
path: '/*',
href: 'https:///*'
}
};