diff --git a/content/articles/web_fs/demo.html b/content/articles/web_fs/demo.html
index 2fcfd4f..941d561 100644
--- a/content/articles/web_fs/demo.html
+++ b/content/articles/web_fs/demo.html
@@ -140,7 +140,7 @@
Local Notes
function generateDownloadLink(filename, content, type = "text/plain") {
// create virtual document
try {
- var blob = new Blob([content], { type });
+ let blob = new Blob([content], { type });
var uri = URL.createObjectURL(blob);
} catch(err) { // fallback for ancient browsers
uri = `data:${type},${encodeURIComponent(content)}`;
@@ -152,7 +152,7 @@ Local Notes
el.setAttribute("href", uri);
return {
el,
- release: () => blob && URL.revokeObjectURL(blob)
+ release: () => uri && URL.revokeObjectURL(uri)
};
}
diff --git a/content/articles/web_fs/index.md b/content/articles/web_fs/index.md
index 953c742..c8e58d1 100644
--- a/content/articles/web_fs/index.md
+++ b/content/articles/web_fs/index.md
@@ -106,9 +106,9 @@ download the respective file instead:
```javascript
function generateDownloadLink(filename, content, type = "text/plain") {
// create virtual document
- let blob, uri;
+ let uri;
try {
- blob = new Blob([content], { type });
+ let blob = new Blob([content], { type });
uri = URL.createObjectURL(blob);
} catch(err) { // fallback for ancient browsers
uri = `data:${type},${encodeURIComponent(content)}`;
@@ -120,7 +120,7 @@ function generateDownloadLink(filename, content, type = "text/plain") {
el.setAttribute("href", uri);
return {
el,
- release: () => blob && URL.revokeObjectURL(blob)
+ release: () => uri && URL.revokeObjectURL(uri)
};
}
```
diff --git a/content/snippets/virtual_modules/demo.html b/content/snippets/virtual_modules/demo.html
index 3c82b05..df04099 100644
--- a/content/snippets/virtual_modules/demo.html
+++ b/content/snippets/virtual_modules/demo.html
@@ -92,9 +92,10 @@ Worker Sample
function code2uri(txt, type = "text/javascript") {
let blob = new Blob([txt], { type });
+ let uri = URL.createObjectURL(blob);
return {
- uri: URL.createObjectURL(blob),
- release: () => URL.revokeObjectURL(blob)
+ uri,
+ release: () => URL.revokeObjectURL(uri)
};
}
diff --git a/content/snippets/virtual_modules/index.md b/content/snippets/virtual_modules/index.md
index 2940207..eca9a24 100644
--- a/content/snippets/virtual_modules/index.md
+++ b/content/snippets/virtual_modules/index.md
@@ -19,9 +19,10 @@ respective source code:
```javascript
function code2uri(txt, type = "text/javascript") {
let blob = new Blob([txt], { type });
+ let uri = URL.createObjectURL(blob);
return {
- uri: URL.createObjectURL(blob),
- release: () => URL.revokeObjectURL(blob)
+ uri,
+ release: () => URL.revokeObjectURL(uri)
};
}
```