edgerender
Version:
Render at the edge
24 lines • 794 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// TODO could use the approach in https://github.com/component/escape-html/blob/master/index.js
// but not sure it would be faster
const html_tags = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' };
const replace_html = (letter) => html_tags[letter] || letter;
class HtmlEscape {
static content(s) {
if (typeof s == 'string') {
return s.replace(/[&<>]/g, replace_html);
}
else {
return '';
}
}
static attr_double(s) {
return s.replace(/[&<>"]/g, replace_html);
}
static attr_single(s) {
return s.replace(/[&<>']/g, replace_html);
}
}
exports.default = HtmlEscape;
//# sourceMappingURL=escape.js.map