Skip to content

Commit

Permalink
url: add a got host pattern in url.js
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
AxelMonroyX authored and MylesBorins committed Jan 24, 2017
1 parent b825b3c commit 3666879
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function Url() {
// compiled once on the first module load.
const protocolPattern = /^([a-z0-9.+-]+:)/i;
const portPattern = /:[0-9]*$/;
const hostPattern = /^\/\/[^@/]+@[^@/]+/;

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

0 comments on commit 3666879

Please sign in to comment.