Skip to content

Commit 3e21af1

Browse files
mbostockmythmon
authored andcommitted
absolute FileAttachment.url (#926)
* absolute FileAttachment.url * update docs
1 parent 42081d9 commit 3e21af1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/javascript/files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ None of the files in `frames` above are loaded until a [content method](#support
9797

9898
The contents often dictate the appropriate method — for example, an Apache Arrow file is almost always read with `file.arrow`. When multiple methods are valid, choose based on your needs. For example, you can load a CSV file using `file.text` to implement parsing yourself instead of using D3.
9999

100-
In addition to the above, you can get the resolved relative path to the file using `file.url`. This returns a [promise](./promises) to a string:
100+
In addition to the above, you can get the resolved absolute URL of the file using `file.url`. This returns a [promise](./promises) to a string:
101101

102102
```js echo
103103
FileAttachment("volcano.json").url()

src/client/stdlib/fileAttachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function FileAttachment(name, base = location.href) {
1212
const file = files.get(url);
1313
if (!file) throw new Error(`File not found: ${name}`);
1414
const {path, mimeType} = file;
15-
return new FileAttachmentImpl(path, name.split("/").pop(), mimeType);
15+
return new FileAttachmentImpl(String(new URL(path, base)), name.split("/").pop(), mimeType);
1616
}
1717

1818
async function remote_fetch(file) {

0 commit comments

Comments
 (0)