manifold/og-image/api/_lib/sanitizer.ts
Austin Chen 4b2412c49c
Set up a custom OpenGraph image generator for social media previews (#20)
* Copy in og-image code

* Add "yarn start" command in lieu of vercel

* Don't require that images be sourced from vercel

* Load in Major Mono and Readex fonts

* Fix vercel config (?)

* Replace default image with Manifold's

* Add some brief instructions on getting started

* In the UI, use the default image

* Fix typescript errors

* More typescript fixing
2022-01-07 12:07:38 -08:00

13 lines
264 B
TypeScript

const entityMap: { [key: string]: string } = {
"&": "&",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;",
"/": "&#x2F;",
};
export function sanitizeHtml(html: string) {
return String(html).replace(/[&<>"'\/]/g, (key) => entityMap[key]);
}