Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: refactor fix some typo, put parents for groups and correct for …
…loop condition
  • Loading branch information
jun-oka committed Dec 24, 2016
commit 835a097b711d2e3cbc74b0e760784e13d2d60d25
10 changes: 5 additions & 5 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,19 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
};

function validateHostname(self, rest, hostname) {
for (var i = 0; i <= hostname.length; ++i) {
for (var i = 0; i < hostname.length; ++i) {
const code = hostname.charCodeAt(i);
const isVc = code === 46/*.*/ ||
code >= 48/*0*/ && code <= 57/*9*/ ||
code >= 97/*a*/ && code <= 122/*\z*/ ||
(code >= 48/*0*/ && code <= 57/*9*/) ||
(code >= 97/*a*/ && code <= 122/*z*/) ||
code === 45/*-*/ ||
code >= 65/*A*/ && code <= 90/*Z*/ ||
(code >= 65/*A*/ && code <= 90/*Z*/) ||
code === 43/*+*/ ||
code === 95/*_*/||
code > 127;

// Invalid host character
if (!isVc && i !== hostname.length) {
if (!isVc) {
self.hostname = hostname.slice(0, i);
return '/' + hostname.slice(i) + rest;
}
Expand Down