All files index.js

100% Statements 12/12
100% Branches 2/2
100% Functions 6/6
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28  2x 33x       1x 2x 2x 2x 1x 1x   1x     1x         1x     2x      
function obfuscate(data) {
	return data.split('').map((v) => {
		return `&#${v.charCodeAt(0)};`;
	}).join('');
}
 
module.exports = () => {
	return (tree) => {
		tree.match({tag: 'a'}, node => {
			if (/^mailto:/.test(node.attrs.href)) {
				let ob = ((email) => {
					return {
						get href() {
							return obfuscate(`mailto:${email}`)
						},
						get content() {
							return obfuscate(email);
						}
					}
				})(node.attrs.href.replace(/^mailto:/, ''));
 
				[node.attrs.href, node.content] = [ob.href, ob.content];
			}
 
			return node;
		});
	}
}