mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-03-29 10:05:49 +00:00
16 lines
410 B
JavaScript
16 lines
410 B
JavaScript
const _ = require('lodash');
|
|
|
|
const tags = {
|
|
'<': '<',
|
|
'>': '>',
|
|
'&': '&',
|
|
};
|
|
const untags = _.invert(tags);
|
|
|
|
module.exports = {
|
|
escapeTags: str => (str || '').replace(/[<>&]/g, m => tags[m]),
|
|
unescapeTags: str =>
|
|
(str || '').replace(/(<|>|&)/g, m => untags[m]),
|
|
stripTags: str => (str || '').replace(/<(?:.|\n)*?>/gm, ''),
|
|
validDomainId: str => /^[\w-_]+$/.test(str),
|
|
};
|