Skip to content

Commit

Permalink
Fix passing file: URI to Zotero.File.getContentsAsync()
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed Jan 14, 2017
1 parent f44264c commit f2440eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chrome/content/zotero/xpcom/file.js
Expand Up @@ -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 = {
Expand Down
7 changes: 7 additions & 0 deletions test/tests/fileTest.js
Expand Up @@ -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 () {
Expand Down

0 comments on commit f2440eb

Please sign in to comment.