data endpoint for entity 90008 (aka. a website)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: reject load if no user agent is provided

dusk c4c4cae9 3764639d

+3 -2
+1
src/lib/robots.ts
··· 44 44 } 45 45 46 46 export const testUa = async (url: string, ua: string) => { 47 + if (ua.length === 0) return false 47 48 let parsedRobots = get(cachedParsedRobots) 48 49 if (parsedRobots === null) { 49 50 parsedRobots = robotsParser(`${PUBLIC_BASE_URL}/robots.txt`, await getRobotsTxt())
+1 -1
src/lib/visits.ts
··· 10 10 11 11 type Visitor = { visits: number[] } 12 12 const lastVisitors = writable<Map<string, Visitor>>(new Map()) 13 - const VISITOR_EXPIRY_SECONDS = 60 * 30 // half an hour seems reasonable 13 + const VISITOR_EXPIRY_SECONDS = 60 * 60 // an hour seems reasonable 14 14 15 15 export const incrementVisitCount = (request: Request, cookies: Cookies) => { 16 16 let currentVisitCount = get(visitCount)
+1 -1
src/routes/+layout.server.ts
··· 11 11 notifyDarkVisitors(url, request) // no await so it doesnt block load 12 12 13 13 // block any requests if the user agent is disallowed by our robots txt 14 - if (await testUa(url.toString(), request.headers.get('user-agent') ?? "unknown user agent") === false) { 14 + if (await testUa(url.toString(), request.headers.get('user-agent') ?? "") === false) { 15 15 throw error(403, "get a better user agent silly") 16 16 } 17 17