diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index af120c7d60..ba7bfe1004 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1043,6 +1043,12 @@ Zotero.Utilities.Internal = { return true; } + // Skip for now, since the mappings to Place will be changed + // https://github.com/citation-style-language/zotero-bits/issues/6 + if (key == 'event-place' || key == 'publisher-place') { + return true; + } + // Fields let possibleFields = fieldNames.get(key); // No valid fields diff --git a/test/tests/utilities_internalTest.js b/test/tests/utilities_internalTest.js index 660fe1a099..0431dd1b6b 100644 --- a/test/tests/utilities_internalTest.js +++ b/test/tests/utilities_internalTest.js @@ -175,24 +175,24 @@ describe("Zotero.Utilities.Internal", function () { }); it("should extract a field with other fields, text, and whitespace", function () { - var place = 'New York'; + var date = '2020-04-01'; var doi = '10.1234/abcdef'; - var str = `Line 1\nPublisher Place: ${place}\nFoo: Bar\nDOI: ${doi}\n\nLine 2`; + var str = `Line 1\nDate: ${date}\nFoo: Bar\nDOI: ${doi}\n\nLine 2`; var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); assert.equal(fields.size, 2); + assert.equal(fields.get('date'), date); assert.equal(fields.get('DOI'), doi); - assert.equal(fields.get('place'), place); assert.equal(extra, 'Line 1\nFoo: Bar\n\nLine 2'); }); it("should extract the first instance of a field", function () { - var place1 = 'New York'; - var place2 = 'London'; - var str = `Publisher Place: ${place1}\nPublisher Place: ${place2}`; + var date1 = '2020-04-01'; + var date2 = '2020-04-02'; + var str = `Date: ${date1}\nDate: ${date2}`; var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); assert.equal(fields.size, 1); - assert.equal(fields.get('place'), place1); - assert.equal(extra, "Publisher Place: " + place2); + assert.equal(fields.get('date'), date1); + assert.equal(extra, "Date: " + date2); }); it("shouldn't extract a field from a line that begins with a whitespace", function () { @@ -265,6 +265,14 @@ describe("Zotero.Utilities.Internal", function () { assert.equal(fields.get('date'), 2014); assert.strictEqual(extra, ''); }); + + it("should ignore both Event Place and Publisher Place (temporary)", function () { + var str = "Event Place: Foo\nPublisher Place: Bar"; + var { fields, extra } = Zotero.Utilities.Internal.extractExtraFields(str); + Zotero.debug([...fields.entries()]); + assert.equal(fields.size, 0); + assert.equal(extra, "Event Place: Foo\nPublisher Place: Bar"); + }); }); describe("#combineExtraFields", function () {