Browse Source

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>
v5.x
Brian White 9 years ago
committed by Rod Vagg
parent
commit
dfe45f13e7
  1. 2
      lib/url.js
  2. 15
      test/parallel/test-url.js

2
lib/url.js

@ -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
test/parallel/test-url.js

@ -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:///*'
}
};

Loading…
Cancel
Save