core/src/common/sanitize.ts

16 lines
369 B
TypeScript
Raw Normal View History

2020-11-28 19:08:23 +00:00
2021-10-02 08:07:01 +00:00
/**
* Remove escaped HTML entities from string.
* @param text HTML escaped string
* @returns Un-escaped string
*/
2020-11-28 19:08:23 +00:00
export function sanitizeEscapedText(text: string): string {
return text.replace(/\n/g, ' ')
.replace(/&/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, '"')
.replace(/&apos;/g, '\'')
.trim();
2020-11-28 19:08:23 +00:00
}