25 lines
No EOL
620 B
JavaScript
25 lines
No EOL
620 B
JavaScript
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
const htmlEntities = {
|
|
'&': '&',
|
|
'&': '&',
|
|
'<': '<',
|
|
'<': '<',
|
|
'>': '>',
|
|
'>': '>',
|
|
''': "'",
|
|
''': "'",
|
|
'"': '"',
|
|
'"': '"',
|
|
' ': ' ',
|
|
' ': ' ',
|
|
'©': '©',
|
|
'©': '©',
|
|
'®': '®',
|
|
'®': '®',
|
|
'…': '…',
|
|
'…': '…',
|
|
'/': '/',
|
|
'/': '/'
|
|
};
|
|
const unescapeHtmlEntity = m => htmlEntities[m];
|
|
export const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity); |