Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ZipArchiveEntry #1126

Merged
merged 1 commit into from Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/client/stdlib/fileAttachment.js
Expand Up @@ -16,7 +16,7 @@ export function FileAttachment(name, base = location) {
}

async function remote_fetch(file) {
const response = await fetch(file.href);
const response = await fetch(await file.url());
if (!response.ok) throw new Error(`Unable to load file: ${file.name}`);
return response;
}
Expand Down Expand Up @@ -57,13 +57,14 @@ export class AbstractFile {
return dsv(this, "\t", options);
}
async image(props) {
const url = await this.url();
return new Promise((resolve, reject) => {
const i = new Image();
if (new URL(this.href, document.baseURI).origin !== new URL(location).origin) i.crossOrigin = "anonymous";
if (new URL(url, document.baseURI).origin !== new URL(location).origin) i.crossOrigin = "anonymous";
Object.assign(i, props);
i.onload = () => resolve(i);
i.onerror = () => reject(new Error(`Unable to load file: ${this.name}`));
i.src = this.href;
i.src = url;
});
}
async arrow() {
Expand Down Expand Up @@ -99,7 +100,6 @@ class FileAttachmentImpl extends AbstractFile {
super(name, mimeType, lastModified);
Object.defineProperty(this, "href", {value: href});
}
/** @deprecated Use this.href instead. */
async url() {
return this.href;
}
Expand Down