const LINKS = { post1: { title: "Discover Something Amazing Today", description: "Explore something new and discover more.", image: "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3A75uRWXCdIFQSREtar08vpTvpYQI6rQwtigZTetAapBxPAcLFnjEKO3LG8Boqcfdb1UZ9rh88SkDyhTcD44gMkrRyMzoCC0gPjLtelnNLBlV3TRDqZWop-ZtTsJ61lOMvZslqwLfZbwf7Fh8NWCTMQPqDSTfp0AmRarnLuEps-erIdudWuCbvs_puUna/s1600/7.jpeg", destination: "https://zz.dennys-menus.com/top-10-most-expensive-hospitals-in-canada-premium-healthcare-and-specialist-treatment-costs/" } }; function escapeHTML(value) { return String(value).replace(/[&<>"']/g, char => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[char]); } export default { async fetch(request) { const url = new URL(request.url); const id = url.pathname.replace(/^\/+|\/+$/g, ""); const item = LINKS[id]; if (!item) { return new Response("Link not found", { status: 404 }); } const ua = request.headers.get("user-agent") || ""; const isFacebookCrawler = /facebookexternalhit|Facebot|meta-externalagent/i.test(ua); // Facebook crawler receives the OG preview metadata. if (isFacebookCrawler) { const html = `
${escapeHTML(item.description)}
Continue `; return new Response(html, { headers: { "content-type": "text/html; charset=UTF-8", "cache-control": "no-cache" } }); } // Normal visitors go directly to the destination. return Response.redirect(item.destination, 302); } };