diff --git a/lib/Server.js b/lib/Server.js index e8af8c87a1..ff25797b34 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -3130,7 +3130,7 @@ class Server { // support "." as a subdomain wildcard // e.g. ".example.com" will allow "example.com", "www.example.com", "subdomain.example.com", etc - if (allowedHost[0] === ".") { + if (allowedHost.startsWith(".")) { // "example.com" (value === allowedHost.substring(1)) // "*.example.com" (value.endsWith(allowedHost)) if ( @@ -3217,12 +3217,7 @@ class Server { hostname.endsWith(".localhost") || hostname === this.options.host; - if (isValidHostname) { - return true; - } - - // disallow - return false; + return isValidHostname; } /**