From 3f2998bb6bcbd0820b83500dbde57e9cb7453048 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 17 Mar 2020 13:50:45 -0400 Subject: [PATCH] Don't extract 'type: note' or 'type: attachment' from Extra --- chrome/content/zotero/xpcom/utilities_internal.js | 5 +++++ test/tests/utilities_internalTest.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 0a2bd62daa..cabcd4f29c 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1012,6 +1012,11 @@ Zotero.Utilities.Internal = { if (key == 'type') { let possibleType = itemTypes.get(value); 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 if (!item || possibleType != Zotero.ItemTypes.getName(itemTypeID)) { itemType = possibleType; diff --git a/test/tests/utilities_internalTest.js b/test/tests/utilities_internalTest.js index 66b947c8dd..4c56f94cdd 100644 --- a/test/tests/utilities_internalTest.js +++ b/test/tests/utilities_internalTest.js @@ -114,6 +114,13 @@ describe("Zotero.Utilities.Internal", 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 () { var str = 'type: motion_picture'; var { itemType, fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str);