actuel-inactuel/site/plugins/loop/frontend/src/composables/decodeHTMLEntities.ts
isUnknown ab7fd8b2ea
All checks were successful
Deploy / Deploy to Production (push) Successful in 6s
add kirby-loop plugin with French translations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 21:41:50 +01:00

19 lines
465 B
TypeScript

/**
* Decodes HTML entities in a string
* @param text The text that may contain HTML entities
* @returns The decoded text
*/
export function decodeHTMLEntities(text: string): string {
const entityMap: Record<string, string> = {
'&amp;': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&#x27;': "'",
'&#x2F;': '/',
'&#x60;': '`',
'&#x3D;': '='
};
return text.replace(/&[#\w]+;/g, (entity) => entityMap[entity] || entity);
}