From 19bb57bc03d96634641600f7f151f9f15d3785c9 Mon Sep 17 00:00:00 2001 From: dusk Date: Thu, 16 Jan 2025 16:22:03 +0300 Subject: [PATCH] fix: make sure to set the visitor after filtering --- src/lib/visits.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/visits.ts b/src/lib/visits.ts index 552c40a..14b582d 100644 --- a/src/lib/visits.ts +++ b/src/lib/visits.ts @@ -48,10 +48,12 @@ const _addLastVisitor = (visitors: Map, request: Request, cooki visitors.forEach((visitor, id, map) => { if (currentTime - visitor.visits[0] > 1000 * VISITOR_EXPIRY_SECONDS) map.delete(id) - else + else { visitor.visits = visitor.visits.filter((since) => { return currentTime - since < 1000 * VISITOR_EXPIRY_SECONDS }) + map.set(id, visitor) + } }) // check whether the request is from a bot or not (this doesnt need to be accurate we just want to filter out honest bots) if (isBot(request)) { return visitors }