Fix file:// URI handling in getBinaryContentsAsync()
This commit is contained in:
parent
8239d04d5e
commit
f1373652e6
2 changed files with 12 additions and 1 deletions
|
@ -311,7 +311,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 = {};
|
||||||
|
|
|
@ -70,6 +70,17 @@ describe("Zotero.File", function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should take a file:// URI", async function () {
|
||||||
|
var file = OS.Path.join(getTestDataDirectory().path, "test.png");
|
||||||
|
var uri = PathUtils.toFileURI(file);
|
||||||
|
|
||||||
|
var contents = await Zotero.File.getBinaryContentsAsync(uri);
|
||||||
|
assert.isAbove(contents.length, magicPNG.length);
|
||||||
|
for (let i = 0; i < magicPNG.length; i++) {
|
||||||
|
assert.equal(magicPNG[i], contents.charCodeAt(i));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("should respect maxLength", function* () {
|
it("should respect maxLength", function* () {
|
||||||
var contents = yield Zotero.File.getBinaryContentsAsync(
|
var contents = yield Zotero.File.getBinaryContentsAsync(
|
||||||
OS.Path.join(getTestDataDirectory().path, "test.png"),
|
OS.Path.join(getTestDataDirectory().path, "test.png"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue