diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index ef5873723e..144e6a4557 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1231,10 +1231,12 @@ Zotero.Utilities.Internal = { if (!key || key != 'type' || skipKeys.has(key) - // 1) Ignore 'type: note' and 'type: attachment' + // 1) Ignore 'type: note', 'type: attachment', 'type: annotation' // 2) Ignore 'article' until we have a Preprint item type // (https://github.com/zotero/translators/pull/2248#discussion_r546428184) - || ['note', 'attachment', 'article'].includes(value)) { + || ['note', 'attachment', 'annotation', 'article'].includes(value) + // Ignore numeric values + || parseInt(value) == value) { return true; } diff --git a/test/tests/utilities_internalTest.js b/test/tests/utilities_internalTest.js index 2224344052..3364e6224c 100644 --- a/test/tests/utilities_internalTest.js +++ b/test/tests/utilities_internalTest.js @@ -142,11 +142,22 @@ 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 ignore 'Type: note', 'Type: attachment', and 'Type: annotation'", function () { + for (let type of ['note', 'attachment', 'annotation']) { + let str = `Type: ${type}`; + let { itemType, extra } = Zotero.Utilities.Internal.extractExtraFields(str); + assert.isNull(itemType, type); + assert.equal(extra, `Type: ${type}`, type); + } + }); + + it("should ignore numeric values for Type", function () { + for (let type of ['3']) { + let str = `Type: ${type}`; + let { itemType, extra } = Zotero.Utilities.Internal.extractExtraFields(str); + assert.isNull(itemType, type); + assert.equal(extra, `Type: ${type}`, type); + } }); it("should use the first mapped Zotero type for a CSL type", function () {