Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
addressparser
Advanced tools
The addressparser npm package is used to parse email addresses into their component parts. It is particularly useful for applications that need to handle email addresses in a structured way, such as email clients, validation tools, and email processing systems.
Parse a single email address
This feature allows you to parse a single email address into its component parts, such as the name and the email address itself.
const addressparser = require('addressparser');
const parsed = addressparser('John Doe <john.doe@example.com>');
console.log(parsed);
Parse multiple email addresses
This feature allows you to parse a string containing multiple email addresses, separating each address into its component parts.
const addressparser = require('addressparser');
const parsed = addressparser('John Doe <john.doe@example.com>, Jane Doe <jane.doe@example.com>');
console.log(parsed);
Handle complex email address formats
This feature allows you to handle and parse more complex email address formats, including those with special characters and quoted names.
const addressparser = require('addressparser');
const parsed = addressparser('"John Doe, PhD" <john.doe@example.com>, Jane Doe <jane.doe@example.com>');
console.log(parsed);
The email-addresses package provides similar functionality to addressparser, allowing you to parse, validate, and manipulate email addresses. It offers more advanced parsing options and better handling of edge cases compared to addressparser.
The mailparser package is a more comprehensive tool for parsing email messages, including headers, attachments, and body content. While it includes email address parsing as part of its functionality, it is more focused on full email message parsing rather than just addresses.
Parse e-mail address fields. Input can be a single address ("andris@kreata.ee"
), a formatted address ("Andris Reinman <andris@kreata.ee>"
), comma separated list of addresses ("andris@kreata.ee, andris.reinman@kreata.ee"
), an address group ("disclosed-recipients:andris@kreata.ee;"
) or a mix of all the formats.
In addition to comma the semicolon is treated as the list delimiter as well (except when used in the group syntax), so a value "andris@kreata.ee; andris.reinman@kreata.ee"
is identical to "andris@kreata.ee, andris.reinman@kreata.ee"
.
Install with npm
npm install addressparser
Include the module
var addressparser = require('addressparser');
Parse some address strings with addressparser(field)
var addresses = addressparser('andris <andris@tr.ee>');
console.log(addresses); // [{name: "andris", address:"andris@tr.ee"}]
And when using groups
addressparser('Composers:"Bach, Sebastian" <sebu@example.com>, mozart@example.com (Mozzie);');
the result would be
[
{
name: "Composers",
group: [
{
address: "sebu@example.com",
name: "Bach, Sebastian"
},
{
address: "mozart@example.com",
name: "Mozzie"
}
]
}
]
Be prepared though that groups might be nested.
This module does not decode any mime-word or punycode encoded strings, it is only a basic parser for parsing the base data, you need to decode the encoded parts later by yourself
MIT
FAQs
Parse e-mail addresses
The npm package addressparser receives a total of 350,175 weekly downloads. As such, addressparser popularity was classified as popular.
We found that addressparser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.