diff --git a/spec/models/contact-spec.coffee b/spec/models/contact-spec.coffee index 59419d78f..8d48dfe2b 100644 --- a/spec/models/contact-spec.coffee +++ b/spec/models/contact-spec.coffee @@ -54,6 +54,15 @@ describe "Contact", -> c8 = new Contact {name: "Mike Kaylor via LinkedIn"} expect(c8.firstName()).toBe "Mike" expect(c8.lastName()).toBe "Kaylor" + c8 = new Contact {name: "Mike Kaylor VIA LinkedIn"} + expect(c8.firstName()).toBe "Mike" + expect(c8.lastName()).toBe "Kaylor" + c8 = new Contact {name: "Mike Viator"} + expect(c8.firstName()).toBe "Mike" + expect(c8.lastName()).toBe "Viator" + c8 = new Contact {name: "Olivia Pope"} + expect(c8.firstName()).toBe "Olivia" + expect(c8.lastName()).toBe "Pope" it "properly parses evan (Evan Morikawa)", -> c8 = new Contact {name: "evan (Evan Morikawa)"} diff --git a/src/flux/models/contact.coffee b/src/flux/models/contact.coffee index b85c42256..93b2f8b31 100644 --- a/src/flux/models/contact.coffee +++ b/src/flux/models/contact.coffee @@ -122,8 +122,8 @@ class Contact extends Model name = name.split(/[()]/)[1] if name.split(/[()]/).length > 1 # Take care of phrases like "Mike Kaylor via LinkedIn" that should be displayed - # as the contents before the separator word. - name = name.split(/(via)/)[0] + # as the contents before the separator word. Do not break "Olivia" + name = name.split(/(\svia\s)/i)[0] # If the phrase has an '@', use everything before the @ sign # Unless that would result in an empty string!