greg 4d1d2f8c52
Some checks failed
continuous-integration/drone Build is failing
maj
2023-06-11 20:17:11 +02:00

24 lines
527 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.escapeHTML = escapeHTML;
// Based on _.escape https://github.com/lodash/lodash/blob/master/escape.js
const reUnescapedHtml = /[&<>"']/g;
const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
const htmlEscapes = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
};
function escapeHTML(s) {
if (reHasUnescapedHtml.test(s)) {
return s.replace(reUnescapedHtml, c => htmlEscapes[c]);
}
return s;
}