An open API service indexing awesome lists of open source software.

https://github.com/johno/normalize-email

Normalize + and . emails -- ex.ample+foobar@gmail.com => example@gmail.com
https://github.com/johno/normalize-email

Last synced: 6 months ago
JSON representation

Normalize + and . emails -- ex.ample+foobar@gmail.com => example@gmail.com

Awesome Lists containing this project

README

          

# normalize-email [![Build Status](https://secure.travis-ci.org/johnotander/normalize-email.png?branch=master)](https://travis-ci.org/johnotander/normalize-email)

Normalize emails for uniqueness validation. This will convert the email to lowercase, remove dots (`.`), and plus signs
followed by arbitrary strings (`+foobar`).

Based on [normailize](https://github.com/soundcloud/normailize).

## Installation

```bash
npm install --save normalize-email
```

## Usage

```javascript
var normalizeEmail = require('normalize-email')

normalizeEmail('johnotander@GMAIL.com') // => 'johnotander@gmail.com'
normalizeEmail('john.o.t.a.n.d.e.r@gmail.com') // => 'johnotander@gmail.com'
normalizeEmail('johnotander@googlemail.com') // => 'johnotander@gmail.com'
normalizeEmail('johnotander+foobar@gmail.com') // => 'johnotander@gmail.com'
normalizeEmail('JOHN.OTANDER+OHAI@gmail.com') // => 'johnotander@gmail.com'
```

## Normalization Rules

Normalization rules vary by domain. The rules implemented by this package are:
1. "plus" — remove first `+` mark and anything after it
1. "dot" — remove all `.` marks
1. "none" — do nothing

Emails are normalized by domain as follows:
1. `gmail.com` — plus and dot
1. `googlemail.com` (alias of gmail.com) — plus and dot
1. hotmail.com — plus only
1. live.com — plus and dot
1. outlook.com — plus only
1. all other domains — none

## License

MIT

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Crafted with <3 by John Otander ([@4lpine](https://twitter.com/4lpine)).

***

> This package was initially generated with [yeoman](http://yeoman.io) and the [p generator](https://github.com/johnotander/generator-p.git).