6 lines
284 B
JavaScript
6 lines
284 B
JavaScript
|
// https://stackoverflow.com/questions/14129953/how-to-encode-a-string-in-javascript-for-displaying-in-html
|
||
|
function htmlEntities(str) {
|
||
|
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||
|
}
|
||
|
|
||
|
module.exports = htmlEntities
|