diff --git a/package.json b/package.json index a4a149b..6eab32a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "Hiverness", "mscdex", "jimmybergman", - "zackschuster" + "zackschuster", + "Yuping Zuo (https://github.com/zypA13510)" ], "repository": { "type": "git", @@ -16,7 +17,8 @@ }, "dependencies": { "addressparser": "^0.3.2", - "emailjs-mime-codec": "^2.0.7" + "emailjs-mime-codec": "^2.0.7", + "lodash.unionwith": "^4.6.0" }, "devDependencies": { "chai": "^4.1.2", @@ -37,8 +39,8 @@ ], "main": "email.js", "scripts": { - "rollup": "rollup -c rollup.config.js && npm run rollup:test", - "rollup:test": "npm run test -- --file rollup/email.bundle.test.js", + "rollup": "rollup -c rollup.config.js && npm run rollup:test", + "rollup:test": "npm run test -- --file rollup/email.bundle.test.js", "test": "mocha" }, "license": "MIT", diff --git a/smtp/client.js b/smtp/client.js index f16a3fc..2b1f931 100644 --- a/smtp/client.js +++ b/smtp/client.js @@ -1,6 +1,9 @@ const { SMTP, state } = require('./smtp'); const { Message, create } = require('./message'); const addressparser = require('addressparser'); +const _ = { + unionWith: require('lodash.unionwith'), +}; class Client { /** @@ -95,11 +98,11 @@ class Client { }; if (message.header.cc) { - stack.to = stack.to.concat(addressparser(message.header.cc)); + stack.to = _.unionWith(stack.to, addressparser(message.header.cc), (x, y) => x.address === y.address); } if (message.header.bcc) { - stack.to = stack.to.concat(addressparser(message.header.bcc)); + stack.to = _.unionWith(stack.to, addressparser(message.header.bcc), (x, y) => x.address === y.address); } if ( diff --git a/yarn.lock b/yarn.lock index 0490fbc..39ca5bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -892,6 +892,11 @@ linkify-it@2.0.3: dependencies: uc.micro "^1.0.1" +lodash.unionwith@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.unionwith/-/lodash.unionwith-4.6.0.tgz#74d140b5ca8146e6c643c3724f5152538d9ac1f0" + integrity sha1-dNFAtcqBRubGQ8NyT1FSU42awfA= + lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"