www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit c5702abb7beedcc329d75ce515ce38678d77d172
parent fc6c113f25e06c40a9c004c1e08a008927183ba5
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 24 Mar 2016 22:26:50 -0400

Don't include 'filename' in linked_file attachment JSON

Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 2+-
Mtest/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 @@ -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 @@ -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 () {