New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

address-rfc2822

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

address-rfc2822 - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

codecov.yml

4

Changes.md

@@ -0,2 +1,6 @@

## 2.0.5 - 2020-06-02
- update email-addresses to 3.1.0
- test framework: nodeunit -> mocha
## 2.0.4 - 2018-06-29

@@ -3,0 +7,0 @@

25

index.js

@@ -39,4 +39,4 @@ 'use strict';

let l = adr.local;
if (!adr.name && /:/.test(l)) l = '"' + l + '"';
return new Address(adr.name, l + '@' + adr.domain, comments);
if (!adr.name && /:/.test(l)) l = `"${ l }"`;
return new Address(adr.name, `${l }@${ adr.domain}`, comments);
}

@@ -63,3 +63,3 @@

format () {
return this.phrase + ":" + this.addresses.map(function (a) { return a.format() }).join(',');
return `${this.phrase }:${ this.addresses.map(function (a) { return a.format() }).join(',')}`;
}

@@ -70,5 +70,3 @@

if (!(phrase && phrase.length)) {
phrase = this.comment;
}
if (!(phrase && phrase.length)) phrase = this.comment;

@@ -110,6 +108,6 @@ const name = _extract_name(phrase);

: _quote_no_esc(phrase) ? phrase
: ('"' + phrase + '"'));
: (`"${phrase}"`));
if (email && email.length) {
addr.push("<" + email + ">");
addr.push(`<${email}>`);
}

@@ -157,3 +155,3 @@ }

const l = match[1];
name = _extract_name(f + " " + l);
name = _extract_name(`${f} ${l}`);
}

@@ -173,5 +171,4 @@

while ((match = /^[\s\S]*?([\s\S])"/.exec(str))) {
if (match[1] !== '\\') {
return true;
}
if (match[1] !== '\\') return true;
str = str.substr(match[0].length);

@@ -200,7 +197,7 @@ }

// Scottish names such as 'McLeod'
return 'Mc' + d1.toUpperCase();
return `Mc${d1.toUpperCase()}`;
})
.replace(/\bo'(\w)/gi, function (_, d1) {
// Irish names such as 'O'Malley, O'Reilly'
return 'O\'' + d1.toUpperCase();
return `O'${d1.toUpperCase()}`;
})

@@ -207,0 +204,0 @@ .replace(/\b(x*(ix)?v*(iv)?i*)\b/ig, function (_, d1) {

{
"name": "address-rfc2822",
"version": "2.0.4",
"version": "2.0.5",
"description": "RFC 2822 (Header) email address parser",

@@ -16,6 +16,6 @@ "main": "index.js",

"scripts": {
"test": "node run_tests",
"lint": "./node_modules/.bin/eslint *.js test/*.js",
"lintfix": "./node_modules/.bin/eslint --fix *.js test/*.js",
"cover": "./node_modules/.bin/istanbul cov run_tests"
"test": "mocha",
"lint": "npx eslint *.js test/*.js",
"lintfix": "npx eslint --fix *.js test/*.js",
"cover": "NODE_ENV=cov npx nyc --reporter=lcovonly -x test npm test"
},

@@ -29,8 +29,8 @@ "repository": {

"eslint-plugin-haraka": "*",
"nodeunit": "*"
"mocha": "*"
},
"license": "MIT",
"dependencies": {
"email-addresses": "^3.0.0"
"email-addresses": "^3.1.0"
}
}

@@ -6,3 +6,2 @@ [![Build Status][ci-img]][ci-url]

[![Dependencies][dep-img]][dep-url]
[![Greenkeeper badge][gk-img]][gk-url]

@@ -56,3 +55,1 @@

[clim-url]: https://codeclimate.com/github/haraka/haraka-plugin-template
[gk-img]: https://badges.greenkeeper.io/haraka/node-address-rfc2822.svg
[gk-url]: https://greenkeeper.io/

@@ -1,19 +0,18 @@

const address = require('../index');
const assert = require('assert')
exports.host = {
'user@example.com' : function (test) {
test.expect(1);
const address = require('../index')
describe('Address', function () {
it('host', function (done) {
const r = new address.Address(null, 'user@example.com');
test.equal(r.host(), 'example.com');
test.done();
},
}
assert.equal(r.host(), 'example.com');
done();
})
exports.user = {
'user@example.com' : function (test) {
test.expect(1);
it('user', function (done) {
const r = new address.Address(null, 'user@example.com');
test.equal(r.user(), 'user');
test.done();
},
}
assert.equal(r.user(), 'user');
done();
})
})
const fs = require('fs');
const path = require('path');
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const parse = require('../index').parse;
const parse = require('../index').parse;
function _check (test, line, details) {
test.expect(Object.keys(details).length);
const parsed = parse(line)[0];
// console.log("Parsed: ", parsed);
for (const k in details) {
test.equal(parsed[k](), details[k], "Test '" + k + "' for '" + parsed[k]() + "' = '" + details[k] + "' from " + JSON.stringify(parsed));
}
test.done();
}
const raw_data = fs.readFileSync(path.join(__dirname, 'emails.txt'), "UTF-8");

@@ -21,2 +12,3 @@

const lines = rows.split(/\n/);
// console.log(lines)
if (lines[0] === '') lines.shift();

@@ -26,12 +18,20 @@ return lines.filter(function (l) { return !/^#/.test(l) });

exports.basic = {};
tests.forEach(function (test) {
const details = {};
details.format = test[1];
if (test[2]) {
details.name = test[2];
}
exports.basic[test[0]] = function (t) {
_check(t, test[0], details);
}
describe('basic parse', function () {
tests.forEach(function (test) {
it(test[0], function () {
const details = {};
details.format = test[1];
if (test[2]) details.name = test[2];
const parsed = parse(test[0])[0];
// console.log('Parsed', parsed);
for (const k in details) {
assert.equal(parsed[k](), details[k], `Test '${k}' for '${parsed[k]()}' = '${details[k]}' from ${JSON.stringify(parsed)}`);
}
})
})
})

@@ -0,53 +1,47 @@

const assert = require('assert')
const address = require('../index');
exports.isAllLower = {
'lower latin string' : function (test) {
test.expect(1);
test.equal(true, address.isAllLower('abcdefg'));
test.done();
},
}
describe('isAllLower', function () {
it('lower latin string', function (done) {
assert.equal(true, address.isAllLower('abcdefg'));
done();
})
})
exports.isAllUpper = {
'upper latin string' : function (test) {
test.expect(1);
test.equal(true, address.isAllUpper('ABCDEFG'));
test.done();
}
}
describe('isAllUpper', function () {
it('upper latin string', function (done) {
assert.equal(true, address.isAllUpper('ABCDEFG'));
done();
})
})
exports.nameCase = {
'john doe -> John Doe' : function (test) {
test.expect(1);
test.equal('John Doe', address.nameCase('john doe'));
test.done();
},
'JANE SMITH -> Jane Smith' : function (test) {
test.expect(1);
test.equal('Jane Smith', address.nameCase('JANE SMITH'));
test.done();
},
'marty mcleod -> Marty McLeod': function (test) {
test.expect(1);
test.equal('Marty McLeod', address.nameCase('marty mcleod'));
test.done();
},
'martin o\'mally -> Martin O\'Malley': function (test) {
test.expect(1);
test.equal("Martin O'Malley", address.nameCase("martin o'malley"));
test.done();
},
'level iii support -> Level III Support': function (test) {
test.expect(1);
test.equal("Level III Support", address.nameCase("level iii support"));
test.done();
}
}
describe('nameCase', function () {
it('john doe -> John Doe', function (done) {
assert.equal('John Doe', address.nameCase('john doe'));
done();
})
it('JANE SMITH -> Jane Smith' , function (done) {
assert.equal('Jane Smith', address.nameCase('JANE SMITH'));
done();
})
it('marty mcleod -> Marty McLeod', function (done) {
assert.equal('Marty McLeod', address.nameCase('marty mcleod'));
done();
})
it('martin o\'mally -> Martin O\'Malley', function (done) {
assert.equal("Martin O'Malley", address.nameCase("martin o'malley"));
done();
})
it('level iii support -> Level III Support', function (done) {
assert.equal("Level III Support", address.nameCase("level iii support"));
done();
})
})
exports.parseFrom = {
'Travis CI <builds@travis-ci.org>': function (test) {
test.expect(1);
describe('parseFrom', function () {
it('Travis CI <builds@travis-ci.org>', function (done) {
try {
const r = address.parseFrom('Travis CI <builds@travis-ci.org>');
test.equal(r[0].address, 'builds@travis-ci.org');
assert.equal(r[0].address, 'builds@travis-ci.org');
// console.log(r);

@@ -58,24 +52,22 @@ }

}
test.done();
},
'root (Cron Daemon)': function (test) {
test.expect(1);
done();
})
it('root (Cron Daemon)', function (done) {
try {
const r = address.parseFrom('root (Cron Daemon)');
test.equal(r[0].address, '');
assert.equal(r[0].address, '');
// console.log(r);
}
catch (e) {
test.equal(e.message, 'No results');
assert.equal(e.message, 'No results');
}
test.done();
}
}
done();
})
})
exports.parseSender = {
'"Anne Standley, PMPM" <info=protectmypublicmedia.org@mail172.atl101.mcdlv.net>': function (test) {
test.expect(1);
describe('parseSender', function () {
it('"Anne Standley, PMPM" <info=protectmypublicmedia.org@mail172.atl101.mcdlv.net>', function (done) {
try {
const r = address.parseSender('"Anne Standley, PMPM" <info=protectmypublicmedia.org@mail172.atl101.mcdlv.net>');
test.equal(r[0].address, 'info=protectmypublicmedia.org@mail172.atl101.mcdlv.net');
assert.equal(r[0].address, 'info=protectmypublicmedia.org@mail172.atl101.mcdlv.net');
// console.log(r);

@@ -86,12 +78,11 @@ }

}
test.done();
}
}
done();
})
})
exports.parseReplyTo = {
'=?utf-8?Q?Anne=20Standley=2C=20Protect=20My=20Public=20Media?= <info@protectmypublicmedia.org>': function (test) {
test.expect(1);
describe('parseReplyTo', function () {
it('=?utf-8?Q?Anne=20Standley=2C=20Protect=20My=20Public=20Media?= <info@protectmypublicmedia.org>', function (done) {
try {
const r = address.parseReplyTo('=?utf-8?Q?Anne=20Standley=2C=20Protect=20My=20Public=20Media?= <info@protectmypublicmedia.org>');
test.equal(r[0].address, 'info@protectmypublicmedia.org');
assert.equal(r[0].address, 'info@protectmypublicmedia.org');
// console.log(r);

@@ -102,4 +93,4 @@ }

}
test.done();
}
}
done();
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc