refactor: 将 Array.indexof !== -1 替换为 Array.includes (#2073)
This commit is contained in:
@@ -21,12 +21,12 @@ module.exports = async (ctx, next) => {
|
||||
await next();
|
||||
} else {
|
||||
if (config.whitelist) {
|
||||
if (!(config.whitelist.indexOf(ip) !== -1 || config.whitelist.indexOf(requestPath) !== -1)) {
|
||||
if (!(config.whitelist.includes(ip) || config.whitelist.includes(requestPath))) {
|
||||
reject(ctx);
|
||||
}
|
||||
} else {
|
||||
if (config.blacklist) {
|
||||
if (config.blacklist.indexOf(ip) !== -1 || config.blacklist.indexOf(requestPath) !== -1) {
|
||||
if (config.blacklist.includes(ip) || config.blacklist.includes(requestPath)) {
|
||||
reject(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user