fix: use foreach because filter isnt available on prod???
All checks were successful
create archive with lfs / tag (push) Successful in 4s

This commit is contained in:
dusk 2025-01-16 15:47:34 +03:00
parent 4e24899c0f
commit f597722892
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw

View File

@ -45,19 +45,14 @@ export const addLastVisitor = (request: Request, cookies: Cookies) => {
const _addLastVisitor = (visitors: Map<string, Visitor>, request: Request, cookies: Cookies) => { const _addLastVisitor = (visitors: Map<string, Visitor>, request: Request, cookies: Cookies) => {
const currentTime = Date.now() const currentTime = Date.now()
// filter out old entries // filter out old entries
visitors = new Map( visitors.forEach((visitor, id, map) => {
visitors.entries().filter( if (currentTime - visitor.visits[0] > 1000 * VISITOR_EXPIRY_SECONDS)
([_, visitor]) => map.delete(id)
{ return currentTime - visitor.visits[0] < 1000 * VISITOR_EXPIRY_SECONDS } else
).map( visitor.visits = visitor.visits.filter((since) => {
([id, visitor]) => { return currentTime - since < 1000 * VISITOR_EXPIRY_SECONDS
visitor.visits = visitor.visits.filter((since) => { })
return currentTime - since < 1000 * VISITOR_EXPIRY_SECONDS })
})
return [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) // 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 } if (isBot(request)) { return visitors }
const scopedCookies = scopeCookies(cookies, '/') const scopedCookies = scopeCookies(cookies, '/')