From b5214aa7a28866cca39e62324b8a5a2fca1f09a5 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 25 May 2013 01:40:38 +0200 Subject: Calculate .name value if not present in the source. Fixes #104 --- importAddrBook.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/importAddrBook.js b/importAddrBook.js index 83256c4..1cb390c 100644 --- a/importAddrBook.js +++ b/importAddrBook.js @@ -201,6 +201,21 @@ } } + // Per RFC 4519 section 3.12 cn and sn attributes are always + // required + if (! contact.hasOwnProperty('name')) { + if (contact.hasOwnProperty('familyName') && + contact.hasOwnProperty('givenName')) { + contact.name = contact.givenName + " " + contact.familyName; + } + else if (contact.hasOwnProperty("org")) { + contact.name = contact.org; + } + else if (contact.hasOwnProperty("jobTitle")) { + contact.name = contact.jobTitle; + } + } + console.log("contact:\n" + contact.toSource()); if (Object.keys(contact).length > 0) { var outObj = new mozContact(); -- cgit