From 38e9fd22a40207e14d8c5e1db4651e1973d73eab Mon Sep 17 00:00:00 2001 From: biglyderv Date: Wed, 28 May 2025 00:35:17 -0400 Subject: [PATCH] fix user pages --- lib.js | 10 +++++++--- views/formatted.ejs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) 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) { %> <%= contentN.data %> <% } } %> \ No newline at end of file