Skip to content

Commit

Permalink
Fixes issue DamienCassou#10 where empty N and FN fields would throw a…
Browse files Browse the repository at this point in the history
…n error

Now just returns an empty string
  • Loading branch information
Daniel Bankmann committed Nov 4, 2019
1 parent 255496e commit ff75055
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/vdirel-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,14 @@
'(("Damien Cassou <[email protected]>" . ("Damien Cassou" "[email protected]"))
("Damien Cassou <[email protected]>" . ("Damien Cassou" "[email protected]")))))))



(describe "contact-no-name"
(it "contacts without FN or F should return empty string"
(expect (vdirel-contact-fullname
'(("EMAIL" . "[email protected]")
("EMAIL;TYPE=home" . "[email protected]")))
:to-equal "")))

(provide 'vdirel-test)
;;; vdirel-test.el ends here
4 changes: 3 additions & 1 deletion vdirel.el
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ Return nil if PROPERTY is not in CONTACT."
"Return the fullname of CONTACT."
(or
(vdirel--contact-property "FN" contact)
(if (equal (vdirel--contact-property "N" contact) nil)
""
(replace-regexp-in-string
";" " "
(vdirel--contact-property "N" contact))))
(vdirel--contact-property "N" contact)))))

(defun vdirel-contact-emails (contact)
"Return a list of CONTACT's email addresses."
Expand Down

0 comments on commit ff75055

Please sign in to comment.