980 B
980 B
Parse Email Address
Extract the local and domain parts of email address strings.
Usage
parseEmailAddress('foo@example.com');
// => {local: 'foo', domain: 'example.com'}
parseEmailAddress('invalid');
// => null
parseEmailAddress('foo@中文.example');
// => {local: 'foo', domain: 'xn--fiq228c.example'}
- Domain names must have at least two labels.
example.comis okay,exampleis not. - The top level domain must have at least two octets.
example.comis okay,example.xis not. - There are various length limits:
- The whole email is limited to 986 octets, per SMTP.
- Domain names are limited to 253 octets, per SMTP.
- Domain labels are limited to 63 octets, per DNS.
Develop
This is a monorepo package.
Follow the instructions for the top-level repo.
git clonethis repo &cdinto it as usual- Run
pnpmto install top-level dependencies.
Test
pnpm lintrun just eslintpnpm testrun lint and tests