mit-license/routes/utils.js
Richie Bendall f189d33f29
fix: Properly parse gravatar boolean and switch to standard linter.
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-01-14 21:05:39 +13:00

16 lines
404 B
JavaScript

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