larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
226 stars 30 forks source link

Subtle bug in type checker #128

Closed larsgw closed 6 years ago

larsgw commented 6 years ago

https://github.com/larsgw/citation.js/blob/61d0bd3bf81af7e97c18c8128101815b068104c1/src/get/modules/ris/index.js#L174

When infoPart.type is a string it shouldn't be tested with .includes(). Subtle, because there's a String.prototype.includes as well as the array version, so it doesn't throw an error. This usually doesn't matter, but it could when, for example, infoPart.type = 'article-journal' and entry.type = 'article'.

Expected behaviour: true when infoPart.type is a string is the same as entry.type or when infoPart.type is an array, one of the elements being the same as entry.type; false otherwise.