jhermsmeier/node-vcf

Parsing Android contacts

Closed this issue · 4 comments

Hi Jonas,

Is this the output you expect?

vCard {
  version: '2.1',
  end: [ { data: 'VCARD' }, { data: 'VCARD' } ],
  begin: [ { data: 'VCARD' }, { data: 'VCARD' } ],
  n: [ { data: 'Bawrie;Allie;;;' }, { data: 'Mickley;Andrew;;;' } ],
  fn: 'Andrew Mickley',
  tel: 
   [ { data: 'CELL;PREF:0427240757' },
     { data: 'HOME:55875233' },
     { data: 'CELL:0429015624' } ] }

For this input?

BEGIN:VCARD
VERSION:2.1
END:VCARD
BEGIN:VCARD
VERSION:2.1
N:Bawrie;Allie;;;
FN:Allie Bawrie
TEL;CELL;PREF:0427240757
TEL;HOME:55875233
END:VCARD
BEGIN:VCARD
VERSION:2.1
N:Mickley;Andrew;;;
FN:Andrew Mickley
TEL;CELL:0429015624
END:VCARD

It seems there's more raw data (and semicolons) and less being recognized/parsed than in your example.

Hey, it currently can't handle multiple VCARD entities in the same input string, so as a quick workaround you could split & map it:

input.split( /(?:^|\r?\n)(?=begin:vcard)/ig )
  .map( vcard.parse )

Aside from that, it is malfunctioning in the way you described – I'll have a look at it.

Hey @bitwombat, just a little heads-up: I rewrote most of this module recently – just some finishing touches to do, but it should get rid of the buggyness you were experiencing – plus, I put in vCard.parseMultiple(value) which will parse multiple vCards out of one input :)

EDIT: See potential version 1.0.0: #7

Great! Thanks for that, and thanks for the package in general. I'll give the new one a try and then close the issue.

Works great! For future bug browsers, parseMultiple is the method that deals with a big .vcf file full of multiple vcards.

Closing...