Skip to content

Commit

Permalink
url: fix off-by-one error with parse()
Browse files Browse the repository at this point in the history
Fixes: #5393
PR-URL: #5394
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
  • Loading branch information
mscdex authored and rvagg committed Feb 28, 2016
1 parent 30cec18 commit dfe45f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,21 @@ var parseTests = {
pathname: '/:npm/npm',
path: '/:npm/npm',
href: 'git+ssh://[email protected]/:npm/npm'
},

'https://*': {
protocol: 'https:',
slashes: true,
auth: null,
host: '',
port: null,
hostname: '',
hash: null,
search: null,
query: null,
pathname: '/*',
path: '/*',
href: 'https:///*'
}

};
Expand Down

0 comments on commit dfe45f1

Please sign in to comment.