nuxt-og-image
Version:
Enlightened OG Image generation for Nuxt.
16 lines (15 loc) • 794 B
JavaScript
export function htmlDecodeQuotes(html) {
return html.replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'");
}
export function decodeHtml(html) {
return html.replace(/</g, "<").replace(/>/g, ">").replace(/¢/g, "\xA2").replace(/£/g, "\xA3").replace(/¥/g, "\xA5").replace(/€/g, "\u20AC").replace(/©/g, "\xA9").replace(/®/g, "\xAE").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(///g, "/").replace(/&#(\d+);/g, (full, int) => {
return String.fromCharCode(Number.parseInt(int));
}).replace(/&/g, "&");
}
export function decodeObjectHtmlEntities(obj) {
Object.entries(obj).forEach(([key, value]) => {
if (typeof value === "string")
obj[key] = decodeHtml(value);
});
return obj;
}