0.1.2 • Published 6 years ago

protect-email v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

protect-email

Linux Build Test Coverage Commitizen friendly NPM version NPM Downloads

Email addresses characters convertor to HTML entities to protect against spam bots and crawlers.

A JavaScript port of Wordpress antispambot.


Installation

$ npm install --save protect-email
# Or with yarn
$ yarn add protect-email

Usage

'use strict';
import { protectEmail, protectEmailAlways, protectEmailFactory } from 'protect-email';

const email = 'test.email@gmail.com';

// Depends on random
const encoded = protectEmail(email);
// => "test.email@gmail.com"
// or
// => "test.email@gmail.com"
// or
// => "test.email@gmail.com"
// etc. (It depends on random)


// With hex encoding
const encoded = protectEmail(email, true);
// => "test.email@g%6dail.%63om"
// or
// => "te%73t.%65m%61%69%6c%40%67ma%69l.c%6fm"
// or
// => "te%73t%2ee%6d%61il@gmai%6c%2ec%6fm"
// etc. (It depends on random)


// Idempotent (always encodes)
const encoded = protectEmailAlways(email);
// => "test.email@gmail.com"


// Or you can specify your own randomize function (`Math.random` by default)
let i = 0;
const myProtectEmail = protectEmailFactory(() => i++ % 2 / 2);

const encoded = myProtectEmail(email);
// => "test.email@gmail.com"

Build

$ npm install
$ # or
$ yarn
$
$ npm run build

Test

$ npm run test

Contributing

  1. Fork it (https://github.com/SuperPaintman/protect-email/fork)
  2. Create your feature branch (git checkout -b feature/<feature_name>)
  3. Commit your changes (git commit -am '<type>(<scope>): added some feature')
  4. Push to the branch (git push origin feature/<feature_name>)
  5. Create a new Pull Request

Contributors


Changelog

Changelog


License

MIT