www

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

commit 56d937214611642f9ff176ea99b9c925ea2386ea
parent f2440eb826d103f50a62ee8b8152f34a1328b524
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 13 Jan 2017 06:51:03 -0500

Throw clearer error if invalid type is passed to File.getContentsAsync()

Diffstat:
Mchrome/content/zotero/xpcom/file.js | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js @@ -273,8 +273,13 @@ Zotero.File = new function(){ if (source instanceof Components.interfaces.nsIFile) { source = source.path; } - else if (source.startsWith('file:')) { - source = OS.Path.fromFileURI(source); + else if (typeof source == 'string') { + if (source.startsWith('file:')) { + source = OS.Path.fromFileURI(source); + } + } + else { + throw new Error(`Unsupported type '${typeof source}' for source`); } var options = { encoding: charset ? charset : "utf-8"