commit f2440eb826d103f50a62ee8b8152f34a1328b524
parent f44264cd4d757c46f4177e537f454d066a4272f1
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 13 Jan 2017 06:48:02 -0500
Fix passing file: URI to Zotero.File.getContentsAsync()
Diffstat:
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js
@@ -273,7 +273,7 @@ Zotero.File = new function(){
if (source instanceof Components.interfaces.nsIFile) {
source = source.path;
}
- else if (source.startsWith('^file:')) {
+ else if (source.startsWith('file:')) {
source = OS.Path.fromFileURI(source);
}
var options = {
diff --git a/test/tests/fileTest.js b/test/tests/fileTest.js
@@ -48,6 +48,13 @@ describe("Zotero.File", function () {
assert.lengthOf(contents, 6);
assert.equal(contents, "Zotero");
});
+
+ it("should get a file from a file: URI", function* () {
+ var contents = yield Zotero.File.getContentsAsync(
+ OS.Path.toFileURI(OS.Path.join(getTestDataDirectory().path, "test.txt"))
+ );
+ assert.isTrue(contents.startsWith('Zotero'));
+ });
})
describe("#getBinaryContentsAsync()", function () {