diff --git a/lib.js b/lib.js
index c2646dc..ac1b875 100644
--- a/lib.js
+++ b/lib.js
@@ -37,7 +37,11 @@ async function splitUp(content) {
let path = new URL(res.slice('file::'.length), 'https://tbg.dervland.net/').pathname;
if (ext == 'txt' || ext == 'json') {
let san = sanitize(path.split('/').pop(), '');
- content = await readFile(`${process.cwd()}/uploads/${san}`, 'utf-8');
+ try {
+ content = await readFile(`${process.cwd()}/uploads/${san}`, 'utf-8');
+ } catch (err) {
+ content = '';
+ }
}
let contentJson = {};
@@ -74,10 +78,10 @@ async function splitUp(content) {
continue;
}
if (res[0] == '#') {
- out[i] = { type: 'link', name: res, href };
+ out[i] = { type: 'link', name: res, href };
continue;
}
- out[i] = {type: 'normal', data: res};
+ out[i] = { type: 'normal', data: res };
}
return out;
}
diff --git a/views/formatted.ejs b/views/formatted.ejs
index 8305983..9d4e31f 100644
--- a/views/formatted.ejs
+++ b/views/formatted.ejs
@@ -23,6 +23,6 @@
<% } else if (contentN.type == 'link') { %>
<%= contentN.name %>
-<% } else if (contentN.data.replaceAll(' ','').length > 0) { %>
+<% } else if (contentN.data && contentN.data.replaceAll(' ','').length > 0) { %>
<% } } %>
\ No newline at end of file