Skip to content

Commit 3ac9e01

Browse files
AxelMonroyXMylesBorins
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 8bccd9e commit 3ac9e01

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: lib/url.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function Url() {
3838
// compiled once on the first module load.
3939
const protocolPattern = /^([a-z0-9.+-]+:)/i;
4040
const portPattern = /:[0-9]*$/;
41+
const hostPattern = /^\/\/[^@/]+@[^@/]+/;
4142

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

0 commit comments

Comments
 (0)