Skip to content

Commit f381a85

Browse files
committed
fix mailto link with multiple emails
1 parent 3263c3b commit f381a85

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/proto/mailto.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ module.exports.check = (link, opts, callback) => {
66
import('node-email-verifier').then((mod) => {
77
const emailValidator = mod.default;
88
const address = link
9-
.substr(7) // strip "mailto:"
10-
.split('?')[0]; // trim ?subject=blah hfields
9+
.substr(7) // strip "mailto:"
10+
.split('?')[0]; // trim ?subject=blah hfields
1111

1212
/* per RFC6068, the '?' is a reserved delimiter and email addresses containing '?' must be encoded,
1313
* so it's safe to split on '?' and pick [0].
1414
*/
1515

16-
emailValidator(address, { checkMx: true, timeout: opts.timeout || '10s' }).then((emailValid) => {
17-
if (!emailValid) {
16+
// multiple addresses separated by commas
17+
const addresses = address.split(',');
18+
19+
Promise.all(
20+
addresses.map(addr =>
21+
emailValidator(addr.trim(), { checkMx: true, timeout: opts.timeout || '10s' })
22+
)
23+
).then((results) => {
24+
if (results.some(valid => !valid)) {
1825
return callback(null, new LinkCheckResult(opts, link, 400, null));
1926
}
2027
return callback(null, new LinkCheckResult(opts, link, 200, null));

0 commit comments

Comments
 (0)