Fix passing file: URI to Zotero.File.getContentsAsync()

This commit is contained in:
Dan Stillman 2017-01-13 06:48:02 -05:00
parent f44264cd4d
commit f2440eb826
2 changed files with 8 additions and 1 deletions

View file

@ -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 = {

View file

@ -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 () {