email-split
v1.0.0
Published
Split an email address into its local and domain parts
Downloads
562
Readme
email-split
Split an email address into its local and domain parts
This was built to grab the name used off of an email address. This library does not perform validation as we retrieve our email addresses from a trusted source.
Getting Started
Install the module with: npm install email-split
var emailSplit = require('email-split');
emailSplit('[email protected]'); /*
{
local: 'todd',
domain: 'underdog.io'
}
*/
Documentation
We expose the function emailSplit
as our module.exports
.
emailSplit(email)
Function that extracts local and domain parts of email address.
- email
String
- Email address to break down
Returns:
- retVal
Object|null
- If the email does not contain an@
, then we returnnull
. Otherwise, we return anObject
.- An
@
is required in a valid email address. We have decided to returnnull
for consistency withArray.match
andString.split
behaviors. - local
String
- Leading portion of email address- For example,
todd
in[email protected]
- For example,
- domain
String
- Tailing portion of email address- For example,
underdog.io
in[email protected]
- For example,
- An
We chose the names
local
anddomain
based off of the RFC specification formailto
.https://tools.ietf.org/html/rfc5322#section-3.4.1
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint
and test via npm test
.
License
Copyright (c) 2015 Underdog.io
Licensed under the MIT license.