From 46f6c280ed29119f80fa6adc6a7ecd383d7aadaa Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Tue, 21 May 2024 17:14:05 +0200 Subject: [PATCH] www: social meta tag bot detection (#2441) --- www/routes/index.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/www/routes/index.tsx b/www/routes/index.tsx index e8ad48ff..0852aaa4 100644 --- a/www/routes/index.tsx +++ b/www/routes/index.tsx @@ -13,18 +13,11 @@ import { Simple } from "$fresh/www/components/homepage/Simple.tsx"; import { SocialProof } from "$fresh/www/components/homepage/SocialProof.tsx"; import { DenoSection } from "$fresh/www/components/homepage/DenoSection.tsx"; -function isOpenGraphUA(header: string | null): boolean { - if (!header) { - return false; - } - return header.startsWith("Twitterbot") || header.startsWith("Slackbot"); -} - export const handler: Handlers = { GET(req, ctx) { const accept = req.headers.get("accept"); const userAgent = req.headers.get("user-agent"); - if (!accept?.includes("text/html") && !isOpenGraphUA(userAgent)) { + if (userAgent?.includes("Deno/") && !accept?.includes("text/html")) { const path = `https://deno.land/x/fresh@${VERSIONS[0]}/init.ts`; return new Response(`Redirecting to ${path}`, { headers: { "Location": path },