Skip to content

Commit 8118d12

Browse files
committed
Ensure that FileAttachment URLs are strings, for compatibility
1 parent e9e9a6f commit 8118d12

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/fileAttachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function remote_fetch(file) {
77
class FileAttachment {
88
constructor(url, name) {
99
Object.defineProperties(this, {
10-
_url: {value: url},
10+
_url: {value: url + ""},
1111
name: {value: name, enumerable: true}
1212
});
1313
}

test/fileAttachments-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,13 @@ test("FileAttachments is exported by stdlib", t => {
66
t.equal(FileAttachments.name, "FileAttachments");
77
t.end();
88
});
9+
10+
test("FileAttachment ensures that URLs are strings", async t => {
11+
const fileAttachments = FileAttachments((name) =>
12+
new URL(`https://example.com/${name}.js`)
13+
);
14+
const file = fileAttachments("filename");
15+
t.equal(file.constructor.name, "FileAttachment");
16+
t.equal(await file.url(), "https://example.com/filename.js");
17+
t.end();
18+
});

0 commit comments

Comments
 (0)