@@ -359,9 +359,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { |
|
|
359 |
359 |
|
360 |
360 |
// validate a little. |
361 |
361 |
if (!ipv6Hostname) { |
362 |
|
-const result = validateHostname(this, rest, hostname); |
363 |
|
-if (result !== undefined) |
364 |
|
-rest = result; |
|
362 |
+rest = getHostname(this, rest, hostname); |
365 |
363 |
} |
366 |
364 |
|
367 |
365 |
if (this.hostname.length > hostnameMaxLen) { |
@@ -462,7 +460,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { |
|
|
462 |
460 |
return this; |
463 |
461 |
}; |
464 |
462 |
|
465 |
|
-function validateHostname(self, rest, hostname) { |
|
463 |
+function getHostname(self, rest, hostname) { |
466 |
464 |
for (var i = 0; i < hostname.length; ++i) { |
467 |
465 |
const code = hostname.charCodeAt(i); |
468 |
466 |
const isValid = (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z) | |
@@ -477,9 +475,10 @@ function validateHostname(self, rest, hostname) { |
|
|
477 |
475 |
// Invalid host character |
478 |
476 |
if (!isValid) { |
479 |
477 |
self.hostname = hostname.slice(0, i); |
480 |
|
-return '/' + hostname.slice(i) + rest; |
|
478 |
+return `/${hostname.slice(i)}${rest}`; |
481 |
479 |
} |
482 |
480 |
} |
|
481 |
+return rest; |
483 |
482 |
} |
484 |
483 |
|
485 |
484 |
// Escaped characters. Use empty strings to fill up unused entries. |