Don't extract 'type: note' or 'type: attachment' from Extra

This commit is contained in:
Dan Stillman 2020-03-17 13:50:45 -04:00
parent 3247391914
commit 3f2998bb6b
2 changed files with 12 additions and 0 deletions

View file

@ -1012,6 +1012,11 @@ Zotero.Utilities.Internal = {
if (key == 'type') { if (key == 'type') {
let possibleType = itemTypes.get(value); let possibleType = itemTypes.get(value);
if (possibleType) { if (possibleType) {
// Ignore 'type: note' and 'type: attachment'
if (['note', 'attachment'].includes(possibleType)) {
keepLines.push(line);
continue;
}
// Ignore item type that's the same as the item // Ignore item type that's the same as the item
if (!item || possibleType != Zotero.ItemTypes.getName(itemTypeID)) { if (!item || possibleType != Zotero.ItemTypes.getName(itemTypeID)) {
itemType = possibleType; itemType = possibleType;

View file

@ -114,6 +114,13 @@ describe("Zotero.Utilities.Internal", function () {
describe("#extractExtraFields()", function () { describe("#extractExtraFields()", function () {
it("should ignore 'type: note' and 'type: attachment'", function () {
var str = 'type: note';
var { itemType, extra } = Zotero.Utilities.Internal.extractExtraFields(str);
assert.isNull(itemType);
assert.equal(extra, 'type: note');
});
it("should extract a CSL type", function () { it("should extract a CSL type", function () {
var str = 'type: motion_picture'; var str = 'type: motion_picture';
var { itemType, fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); var { itemType, fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str);