https://github.com/superpaintman/protect-email
Email addresses characters convertor to HTML entities to protect against spam bots and crawlers
https://github.com/superpaintman/protect-email
antispam antispambot spam-protection
Last synced: 3 months ago
JSON representation
Email addresses characters convertor to HTML entities to protect against spam bots and crawlers
- Host: GitHub
- URL: https://github.com/superpaintman/protect-email
- Owner: SuperPaintman
- License: mit
- Created: 2018-05-22T06:30:36.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T07:36:40.000Z (almost 7 years ago)
- Last Synced: 2025-02-17T01:34:09.261Z (3 months ago)
- Topics: antispam, antispambot, spam-protection
- Language: TypeScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# protect-email
[![Linux Build][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Commitizen friendly][commitizen-image]][commitizen-url]
[![NPM version][npm-v-image]][npm-url]
[![NPM Downloads][npm-dm-image]][npm-url]Email addresses characters convertor to HTML entities to protect against spam
bots and crawlers.A JavaScript port of [Wordpress `antispambot`][wordpress-antispambot-url].
--------------------------------------------------------------------------------
## Installation
```sh
$ npm install --save protect-email
# Or with yarn
$ yarn add protect-email
```--------------------------------------------------------------------------------
## Usage
```ts
'use strict';
import { protectEmail, protectEmailAlways, protectEmailFactory } from 'protect-email';const email = '[email protected]';
// Depends on random
const encoded = protectEmail(email);
// => "[email protected]"
// or
// => "[email protected]"
// or
// => "[email protected]"
// 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);
// => "[email protected]"// 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);
// => "[email protected]"
```--------------------------------------------------------------------------------
## Build
```sh
$ npm install
$ # or
$ yarn
$
$ npm run build
```--------------------------------------------------------------------------------
## Test
```sh
$ npm run test
```--------------------------------------------------------------------------------
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b feature/`)
3. Commit your changes (`git commit -am '(): added some feature'`)
4. Push to the branch (`git push origin feature/`)
5. Create a new Pull Request--------------------------------------------------------------------------------
## Contributors
- [SuperPaintman](https://github.com/SuperPaintman) SuperPaintman - creator, maintainer
--------------------------------------------------------------------------------
## Changelog
[Changelog][changelog-url]--------------------------------------------------------------------------------
## License
[MIT][license-url]
[license-url]: https://raw.githubusercontent.com/SuperPaintman/protect-email/master/LICENSE
[changelog-url]: https://raw.githubusercontent.com/SuperPaintman/protect-email/master/CHANGELOG.md
[npm-url]: https://www.npmjs.com/package/protect-email
[npm-v-image]: https://img.shields.io/npm/v/protect-email.svg
[npm-dm-image]: https://img.shields.io/npm/dm/protect-email.svg
[travis-image]: https://img.shields.io/travis/SuperPaintman/protect-email/master.svg?label=linux
[travis-url]: https://travis-ci.org/SuperPaintman/protect-email
[coveralls-image]: https://img.shields.io/coveralls/SuperPaintman/protect-email/master.svg
[coveralls-url]: https://coveralls.io/r/SuperPaintman/protect-email?branch=master
[commitizen-image]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[commitizen-url]: https://commitizen.github.io/cz-cli/
[wordpress-antispambot-url]: https://core.trac.wordpress.org/browser/tags/4.9.6/src/wp-includes/formatting.php#L2500