Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions lib/vcardparser.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
/*
* @package vcardparser
* @copyright () Wouter Vroege <wouter AT woutervroege DOT nl>
* @copyright (©) Wouter Vroege <wouter AT woutervroege DOT nl>
* @author Wouter Vroege <wouter AT woutervroege DOT nl>
*/

/*
parse vcard to object
*/

function parseVCardToObject(vcard) {
card = stripUnixChars(vcard);
cardLines = splitAtNewLines(card);
propertyLines = evalProperties(cardLines);
propertiesChunks = parseLinesToPropertiesChunks(propertyLines);
properties = parseChunksToProperties(propertiesChunks);
return properties;
function parseVCardToObject(data) {
vcards = splitCards(data);
var properties = [];
for (var i in vcards) {
card = stripUnixChars(vcards[i]);
cardLines = splitAtNewLines(card);
propertyLines = evalProperties(cardLines);
propertiesChunks = parseLinesToPropertiesChunks(propertyLines);
properties.push(parseChunksToProperties(propertiesChunks));
}
return properties;
}

/*
split multiple cards
*/

function splitCards(string) {
var vcards = string.split('BEGIN:VCARD');
vcards.shift();
vcards.map(function (i) {
return 'BEGIN:VCARD' + i;
});
return vcards;
}
/*
parse string
*/
Expand Down Expand Up @@ -301,4 +317,4 @@ function parsePhoto(base64string, types) {

//export
exports.parseString = parseString;
exports.parseFile = parseFile;
exports.parseFile = parseFile;