Code Monkey home page Code Monkey logo

vcard4's People

Contributors

kelseykm avatar marcelwaldvogel avatar thebthinker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vcard4's Issues

Safari IOS and MacOS. Unexpected private name #validate.

I am getting the following on safari IOS and MacOS

Unhandled Runtime Error
SyntaxError: Unexpected private name #validate. Cannot parse class method with private name.

./node_modules/vcard4/src/esm/values.js

file:///Users/tim/src/active/.next/static/chunks/pages/v1/%5Bsource%5D/%5Btapid%5D.js (4525:5)

NextJS 11. Works fine on Chrome and Firefox.

Any ideas?

Thanks

Tim

"npm run test" fails due to private class fields

Environment: Ubuntu 21.10 (node v12.22.5)

git checkout https://github.com/keseykm/vcard4.git
cd vcard4
npm i
npm run test

results in

> [email protected] test
> mocha

/home/marcel/Repos/vcard4/src/cjs/values.js:38
  #validate(textValue) {
           ^

SyntaxError: Unexpected token '('
[…]

Running npm -D i node, i.e., updating to node 17.0.1 for the repository, fixes this. However, as the installed node 12.22.5 should already support this feature by default, I doubt that this is the best fix.

round trip test case

Thanks for this awesome library.

it would be nice to have a round trip test case in the documentation, something like this:

  const card = new VCARD([ ... ]);
  fs.writeFileSync('example-card.vcf', card.repr()); // to xml
  const serializedCard = fs.readFileSync('example-card.vcf').toString() // from xml
  const card2 = VCARD.from(serializedCard);
  // expect card2 to equal card 1

As a developer, I want to be assured that all properties that are imported are preserved, then I want to add a property and export.

This seems possible with the existing parse API, but its not intuitive or obvious how exactly to do this.

Sorry if I missed this in the docs or tests.

No support for escaped backslashes in parser

Fields ending in (properly escaped) backslashes will cause the field delimiter to be ignored. E.g.

NICKNAME:Backslash\\,The weird guy

should result in two value strings, Backslash\ and The weird guy. However, it will be parsed as Backslash\,The weird guy, due to the look-back logic.

Yes, this is probably rare/a constructed case. And yes, it is hard to implement with your current parser logic.

(I'm fine with several of my issues being closed as WONTFIX; I just noticed them while reading RFC6350.)

Accept bare newlines as well

To support the IETF's general Robustness principle, I would recommend to accept bare newlines as well on parsing. However, I would also understand if you wanted to remain tight on what input you wanted to accept.

Constructor not accept Groups

In Version: 3.1.0

The typescript constructor does not support groups as shown in the documentation. https://kelseykm.github.io/vcard4/documentation/vcard

Error:

Type 'Group' is not assignable to type 'SourceProperty | KindProperty | XMLProperty | FNProperty | NProperty | NicknameProperty | ... 37 more ... | ExtendedProperty'.
Type 'Group' is missing the following properties from type 'ExtendedProperty': params, paramsXML, paramsJSON, value, and 2 more.ts(2322)

[Bug] A hyphen is used after 'X-' in an ExtendedProperty, an 'Invalid property for ExtendedProperty' error occurs

In Japan, the unique property X-PHONETIC-FIRST-NAME (and X-PHONETIC-LAST-NAME) is often used to indicate the ruby of a name. However, this library cannot create vCards with an error if X- followed by a hyphen is included.

Code sample: https://github.com/argxentakato/20231102-for-vcard4-issue

Expected Behavior

BEGIN:VCARD
VERSION:4.0
FN:Unuaviro F. Arĝentakato
X-CAR:Subaru
END:VCARD

BEGIN:VCARD
VERSION:4.0
FN:Unuaviro F. Arĝentakato
X-PHONETIC-FIRST-NAME:ウヌアヴィーロ
END:VCARD

Current Behavior

BEGIN:VCARD
VERSION:4.0
FN:Unuaviro F. Arĝentakato
X-CAR:Subaru
END:VCARD

file://.../20231102-for-vcard4-issue/node_modules/.pnpm/[email protected]/node_modules/vcard4/lib/esm/properties/ExtendedProperty.js:102
  if (typeof prop === "undefined" || typeof params === "undefined" || typeof value === "undefined") throw new MissingArgument("Property, parameter and value for ExtendedProperty must be supplied");else if (!Array.isArray(params)) throw new InvalidArgument("Parameters for ExtendedProperty must be passed in an array");else if (!_classPrivateFieldGet(this, _propRegExp).test(prop)) throw new InvalidArgument("Invalid property for ExtendedProperty");



                           ^

InvalidArgument: Invalid property for ExtendedProperty
    at ExtendedProperty._validate2 (file://..../20231102-for-vcard4-issue/node_modules/.pnpm/[email protected]/node_modules/vcard4/lib/esm/properties/ExtendedProperty.js:102:388)
    at new ExtendedProperty (file://..../20231102-for-vcard4-issue/node_modules/.pnpm/[email protected]/node_modules/vcard4/lib/esm/properties/ExtendedProperty.js:43:82)
    at file://..../20231102-for-vcard4-issue/index.js:14:3
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Support parsing multiple vCards in a single file

RFC6350 6.1.1 BEGIN says:

[The BEGIN property] is provided for applications that wish to define content that can contain multiple entities within the same text/vcard content-type […]

I understand this as "there might be multiple vCard entities in a single file. Be prepared". This is also supported by several address books exporting multiple entries as a single vCard file.

A minimalistic way (besides delegating the entire work to the caller) would be to exit the loop after reading an END property and return the unparsed remainder of the file to the caller.

It would be helpful to have charset support included, even if it's added to AnyParameter.

In order to support other languages, I need to add charset to the vCard and generate the vCard string as follows:

BEGIN:VCARD
VERSION:4.0
FN;CHARSET=UTF-8:姓名
TITLE;CHARSET=UTF-8:职位
ORG;CHARSET=UTF-8:公司;;
END:VCARD

I haven't been able to find a method that supports charset, so I currently manually add CHARSET to paramRegExp in AnyParameter and rebuild.
It would be helpful to have charset support included, even if it's added to AnyParameter.

Typings are wrong

Using the return type parsedVCard says I only have two prop "values" and "parameters" but actually it is returning an object of parsedVCard.

Bildschirmfoto 2021-12-09 um 09 53 28

Potential fix would be:

declare interface VCardProperty = {
  parameter: VCardParameter
  value: VCardValue
}
declare type ParsedVCard = Record<Uppercase<string>, VCardProperty>

Please note that I intentionally modified your type names a little, so these are more specific to vcard4 and not too generic. Types should also start capitalized, not to confuse with values and functions.

Issue attaching base64 images

EDIT: To save others time reading.. make sure your test device can read version 4 of vCards, otherwise photos may not work.

I've tried a combination of different photo properties combined with the URIType and was unable to get the correct combination.

A not-so-elegant hack:

// setting the photo property
new PhotoProperty([], new URIType(`ENCODING=b;MEDIATYPE=image/image/png:${base64_image}`)));
...
// replacing the colon after PHOTO with a semicolon
vc.repr().replace('PHOTO:', 'PHOTO;')

I was hoping to find a more elegant solution, if possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.