@already-existed/email-obfuscator
v1.1.2
Published
Lib for obfuscate email on server and unobfuscate on client.
Downloads
33
Maintainers
Readme
EmailObfuscator
Lib for obfuscate email on server and unobfuscate on client.
Installation
npm i -S @already-existed/email-obfuscator
Usage
<!-- html -->
<a data-email="true" href="mailto:[email-href][email protected][/email-href]">
[email][email protected][/email]
</a>
// server
import { obfuscateEmail } from '@already-existed/email-obfuscator'
...
res.send(obfuscateEmail(html))
...
// client
import { unobfuscateEmail } from '@already-existed/email-obfuscator'
window.addEventListener('load', () => {
unobfuscateEmail()
})
Options
// 'binary' - slow
// 'base64' - fast
type ObfuscateType = 'binary' | 'base64'
interface ObfuscateOptions {
type?: ObfuscateType // default: 'binary'
}
obfuscateEmail(value: string, opts?: ObfuscateOptions): string
unobfuscateEmail(opts?: ObfuscateOptions): void