Skip to content

Commit 4367a5c

Browse files
authored
refactor: use 'String#startsWith' & replace if-then-else (#5501)
1 parent 8e6604f commit 4367a5c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/Server.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3130,7 +3130,7 @@ class Server {
31303130

31313131
// support "." as a subdomain wildcard
31323132
// e.g. ".example.com" will allow "example.com", "www.example.com", "subdomain.example.com", etc
3133-
if (allowedHost[0] === ".") {
3133+
if (allowedHost.startsWith(".")) {
31343134
// "example.com" (value === allowedHost.substring(1))
31353135
// "*.example.com" (value.endsWith(allowedHost))
31363136
if (
@@ -3217,12 +3217,7 @@ class Server {
32173217
hostname.endsWith(".localhost") ||
32183218
hostname === this.options.host;
32193219

3220-
if (isValidHostname) {
3221-
return true;
3222-
}
3223-
3224-
// disallow
3225-
return false;
3220+
return isValidHostname;
32263221
}
32273222

32283223
/**

0 commit comments

Comments
 (0)