Fix regression: download() fails for non-http URLs (#2497)

This fixes compatiblity with some addons that use Zotero.File.download
to extract files from their XPI bundle.
This commit is contained in:
Tom Najdek 2022-03-30 18:15:40 +02:00 committed by GitHub
parent 776769f480
commit 56321a7a6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -525,5 +525,13 @@ describe("Zotero.File", function () {
assert.equal(fileSize, 1024 * 1024 * sizeInMB);
}
});
it("should extract a file from xpi", async function () {
const url = `jar:file://${getTestDataDirectory().path}/fake.xpi!/test.txt`;
const path = OS.Path.join(Zotero.getTempDirectory().path, 'xpi-extracted.txt');
await Zotero.File.download(url, path);
const contents = await Zotero.File.getContentsAsync(path);
assert.equal(contents, 'Hello Zotero\n');
});
});
})