From 0eac2abb8ef1bd340c2ac487d33d91798043ff9f Mon Sep 17 00:00:00 2001 From: Justin Langston Date: Wed, 9 Jan 2019 13:45:36 -0500 Subject: [PATCH] simpler startsWith --- packages/bitcore-node/src/routes/middleware.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/bitcore-node/src/routes/middleware.ts b/packages/bitcore-node/src/routes/middleware.ts index 9d3b51e3973..5f74c7e58e3 100644 --- a/packages/bitcore-node/src/routes/middleware.ts +++ b/packages/bitcore-node/src/routes/middleware.ts @@ -68,12 +68,7 @@ export function CacheMiddleware(serverSeconds = CacheTimes.Second, browserSecond } function isWhiteListed(whitelist: Array = [], ip: string) { - let whiteListed = whitelist.includes(ip); - if (whiteListed) { - return true; - } else { - return whitelist.some(listItem => new RegExp(listItem).test(ip)); - } + return whitelist.some(listItem => ip.startsWith(listItem)); } export function RateLimiter(method: string, perSecond: number, perMinute: number, perHour: number) {