homepage.js/helpers/htmlstring.js

6 lines
284 B
JavaScript
Raw Normal View History

2023-02-25 07:32:11 +01:00
// https://stackoverflow.com/questions/14129953/how-to-encode-a-string-in-javascript-for-displaying-in-html
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
module.exports = htmlEntities