From c5702abb7beedcc329d75ce515ce38678d77d172 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 24 Mar 2016 22:26:50 -0400 Subject: [PATCH] Don't include 'filename' in linked_file attachment JSON --- chrome/content/zotero/xpcom/data/item.js | 2 +- test/tests/itemTest.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index bbb5ebaf6d..9216d90e83 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -4093,7 +4093,7 @@ Zotero.Item.prototype.toJSON = function (options = {}) { if (linkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) { obj.path = this.attachmentPath; } - else { + else if (linkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) { obj.filename = this.attachmentFilename; } diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js index 1a05fcbd54..a5a327ce05 100644 --- a/test/tests/itemTest.js +++ b/test/tests/itemTest.js @@ -986,6 +986,15 @@ describe("Zotero.Item", function () { assert.isNull(json.mtime); assert.isNull(json.md5); }) + + it("shouldn't include filename or path for linked_url attachments", function* () { + var item = new Zotero.Item('attachment'); + item.attachmentLinkMode = 'linked_url'; + item.url = "https://www.zotero.org/"; + var json = item.toJSON(); + assert.notProperty(json, "filename"); + assert.notProperty(json, "path"); + }); }) describe("'full' mode", function () {