[local-sync] Fix contact parsing from T7327

Summary: See description at T7327

Test Plan: Manual, but this should have unit tests

Reviewers: mark, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3513
This commit is contained in:
Juan Tejada 2016-12-15 01:15:51 -08:00
parent e17b6d8d17
commit 3910799683

View file

@ -24,9 +24,14 @@ function extractContacts(input) {
const s = `["${input[0].replace(/"/g, '\\"').replace(/, /g, '", "')}"]`;
const values = JSON.parse(s);
return values.map(v => {
const {name, address: email} = mimelib.parseAddresses(v).pop()
const parsed = mimelib.parseAddresses(v)
if (!parsed || parsed.length === 0) {
return null
}
const {name, address: email} = parsed.pop()
return {name, email}
})
.filter(c => c != null)
}
/*