Fix passing file: URI to Zotero.File.getContentsAsync()
This commit is contained in:
parent
f44264cd4d
commit
f2440eb826
|
@ -273,7 +273,7 @@ Zotero.File = new function(){
|
||||||
if (source instanceof Components.interfaces.nsIFile) {
|
if (source instanceof Components.interfaces.nsIFile) {
|
||||||
source = source.path;
|
source = source.path;
|
||||||
}
|
}
|
||||||
else if (source.startsWith('^file:')) {
|
else if (source.startsWith('file:')) {
|
||||||
source = OS.Path.fromFileURI(source);
|
source = OS.Path.fromFileURI(source);
|
||||||
}
|
}
|
||||||
var options = {
|
var options = {
|
||||||
|
|
|
@ -48,6 +48,13 @@ describe("Zotero.File", function () {
|
||||||
assert.lengthOf(contents, 6);
|
assert.lengthOf(contents, 6);
|
||||||
assert.equal(contents, "Zotero");
|
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 () {
|
describe("#getBinaryContentsAsync()", function () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user