mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 15:15:12 +08:00
fix(contact): fix bug where malformed contacts threw an error
Summary: Also added tests to catch the case Fixes T4290 Test Plan: new tests Reviewers: bengotow Reviewed By: bengotow Maniphest Tasks: T4290 Differential Revision: https://phab.nylas.com/D2153
This commit is contained in:
parent
abe0e1baac
commit
78a3218c26
2 changed files with 16 additions and 2 deletions
|
@ -139,6 +139,18 @@ describe "ContactStore", ->
|
|||
expect(ContactStore.isValidContact(new Contact(name: 'Ben', email:'<ben@nylas.com>'))).toBe(false)
|
||||
expect(ContactStore.isValidContact(new Contact(name: 'Ben', email:'"ben@nylas.com"'))).toBe(false)
|
||||
|
||||
it "returns false if we're not passed a contact", ->
|
||||
expect(ContactStore.isValidContact()).toBe false
|
||||
|
||||
it "returns false if the contact doesn't have an email", ->
|
||||
expect(ContactStore.isValidContact(new Contact(name: "test"))).toBe false
|
||||
|
||||
it "returns false if the email doesn't satisfy the regex", ->
|
||||
expect(ContactStore.isValidContact(new Contact(name: "test", email: "foo"))).toBe false
|
||||
|
||||
it "returns false if the email doesn't match", ->
|
||||
expect(ContactStore.isValidContact(new Contact(name: "test", email: "foo@"))).toBe false
|
||||
|
||||
describe 'parseContactsInString', ->
|
||||
testCases =
|
||||
# Single contact test cases
|
||||
|
|
|
@ -116,8 +116,10 @@ class ContactStore extends NylasStore
|
|||
return false unless contact.email
|
||||
|
||||
# The email regexp must match the /entire/ email address
|
||||
[match] = RegExpUtils.emailRegex().exec(contact.email)
|
||||
return match is contact.email
|
||||
result = RegExpUtils.emailRegex().exec(contact.email)
|
||||
if result and result instanceof Array
|
||||
return result[0] is contact.email
|
||||
else return false
|
||||
|
||||
parseContactsInString: (contactString, options={}) =>
|
||||
{skipNameLookup} = options
|
||||
|
|
Loading…
Reference in a new issue