summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAxel Monroy <xaxelmonroyx@gmail.com>2016-12-06 11:04:00 -0700
committerJames M Snell <jasnell@gmail.com>2016-12-06 12:37:24 -0800
commit1be73e828d27da8ab1a45f051506c1b71634c53e (patch)
tree56afbbbf06624a5ddde543bce083c2b81b9077d0 /lib
parent6ade6dedabf14b2403b49ae71f3ef43269cc9cff (diff)
downloadnode-new-1be73e828d27da8ab1a45f051506c1b71634c53e.tar.gz
url: add a got host pattern in url.js
Add a hostPattern variable for readable purposes PR-URL: https://github.com/nodejs/node/pull/9653 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/url.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/url.js b/lib/url.js
index 03a9fb03df..75f4967ad2 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -42,6 +42,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]*)?$/;
@@ -204,7 +205,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])) {