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, "&").replace(/</g, "<");
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}`,
},
},
);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
September 7, 2024