Skip to content

Commit

Permalink
Fix checkHost
Browse files Browse the repository at this point in the history
fixed #1604
  • Loading branch information
3846masa committed Dec 22, 2018
1 parent ff2874f commit 1c56116
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,12 @@ Server.prototype.checkHost = function (headers, headerToCheck) {
}

// use the node url-parser to retrieve the hostname from the host-header.
const hostname = url.parse(`//${hostHeader}`, false, true).hostname;
const hostname = url.parse(
// if hostHeader doesn't have scheme, add // for parsing.
/^(.+:)?\/\//.test(hostHeader) ? hostHeader : `//${hostHeader}`,
false,
true,
).hostname;
// always allow requests with explicit IPv4 or IPv6-address.
// A note on IPv6 addresses:
// hostHeader will always contain the brackets denoting
Expand Down

0 comments on commit 1c56116

Please sign in to comment.