mit-license/routes/utils.js
Richie Bendall 684f358fae
chore: Simplify github constant and normalize string variable used in utils
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2019-08-07 20:02:04 +12:00

8 lines
261 B
JavaScript

const tags = {
'<': '&lt;',
'>': '&gt;',
'&': '&amp;',
};
exports.escapeTags = str => (str || '').replace(/[<>&]/g, m => tags[m]);
exports.stripTags = str => (str || '').replace(/<(?:.|\n)*?>/gm, '');
exports.validDomainId = str => /^[\w-_]+$/.test(str);