Skip to content

Commit 19d7197

Browse files
AxelMonroyXFishrock123
authored andcommitted
url: add a got host pattern in url.js
Add a hostPattern variable for readable purposes PR-URL: #9653 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 3034038 commit 19d7197

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/url.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function Url() {
4242
// compiled once on the first module load.
4343
const protocolPattern = /^([a-z0-9.+-]+:)/i;
4444
const portPattern = /:[0-9]*$/;
45+
const hostPattern = /^\/\/[^@/]+@[^@/]+/;
4546

4647
// Special case for a simple path URL
4748
const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;
@@ -204,7 +205,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
204205
// user@server is *always* interpreted as a hostname, and url
205206
// resolution will treat //foo/bar as host=foo,path=bar because that's
206207
// how the browser resolves relative URLs.
207-
if (slashesDenoteHost || proto || /^\/\/[^@/]+@[^@/]+/.test(rest)) {
208+
if (slashesDenoteHost || proto || hostPattern.test(rest)) {
208209
var slashes = rest.charCodeAt(0) === 47/*/*/ &&
209210
rest.charCodeAt(1) === 47/*/*/;
210211
if (slashes && !(proto && hostlessProtocol[proto])) {

0 commit comments

Comments
 (0)