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 edb3858
Show file tree
Hide file tree
Showing 2 changed files with 13 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
5 changes: 4 additions & 1 deletion vdirel.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

;; Author: Damien Cassou <[email protected]>
;; Version: 0.1.1
;; Package-Version: 20190430.624
;; Url: https://github.com/DamienCassou/vdirel
;; Package-Requires: ((emacs "24.4") (org-vcard "0.1.0") (helm "1.7.0") (seq "1.11"))
;; Created: 09 Dec 2015
Expand Down Expand Up @@ -84,9 +85,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 edb3858

Please sign in to comment.