16 lines
369 B
TypeScript
16 lines
369 B
TypeScript
|
|
/**
|
|
* Remove escaped HTML entities from string.
|
|
* @param text HTML escaped string
|
|
* @returns Un-escaped string
|
|
*/
|
|
export function sanitizeEscapedText(text: string): string {
|
|
return text.replace(/\n/g, ' ')
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"')
|
|
.replace(/'/g, '\'')
|
|
.trim();
|
|
}
|