Skip to content

Commit b8c2f54

Browse files
committed
hostWhitelist matching reduce => some
1 parent 87443b6 commit b8c2f54

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/fastboot-request.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@ class FastBootRequest {
2323
}
2424

2525
var host = this.headers.get('host');
26-
27-
var matchFound = this.hostWhitelist.reduce(function(previous, currentEntry) {
28-
if (currentEntry[0] === '/' &&
29-
currentEntry.slice(-1) === '/') {
30-
// RegExp as string
31-
var regexp = new RegExp(currentEntry.slice(1, -1));
32-
33-
return previous || regexp.test(host);
26+
var matchFound = this.hostWhitelist.some(function(entry) {
27+
if (entry[0] === '/' && entry.slice(-1) === '/') {
28+
var regexp = new RegExp(entry.slice(1, -1));
29+
return regexp.test(host);
3430
} else {
35-
return previous || currentEntry === host;
31+
return entry === host;
3632
}
37-
}, false);
33+
});
3834

3935
if (!matchFound) {
4036
throw new Error(`The host header did not match a hostWhitelist entry. Host header: ${host}`);

0 commit comments

Comments
 (0)