mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(names): "Olivia" should not be caught by name cleanup
This fixes #393. The name "Olivia" was being caught in our parser designed to shorten "Mike Kaylor via LinkedIn" to "Mike Kaylor". We now check that "via" is it's own distinct word in the phrase.
This commit is contained in:
parent
a3346b2338
commit
83510d0cef
2 changed files with 11 additions and 2 deletions
|
@ -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)"}
|
||||
|
|
|
@ -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!
|
||||
|
|
Loading…
Reference in a new issue