1
2
3
4
5
6
7
8
9
10
11
12
13
14
export function svgEmoji(req: Request) {
const url = new URL(req.url);
const emoji = decodeURIComponent(url.pathname.slice(1));
const cleanEmoji = emoji.replace(/&/g, "&amp;").replace(/</g, "&lt;");
return new Response(
`<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 16 16'><text x='0' y='14'>${cleanEmoji}</text></svg>`,
{
headers: {
"Content-Type": "image/svg+xml",
"Cache-Control": `public, max-age=${60 * 60 * 24}, s-maxage=${60 * 60 * 24}`,
},
},
);
}