« get me outta code hell

Merge branch 'preview' into image-overlay - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write/build-modes
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-02-26 18:03:58 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-02-26 18:03:58 -0400
commit7bf9489f14735f9e44af37f2ade14890a119b403 (patch)
tree8b7742140ceeeda283edfe05f745d0e1a06050fe /src/write/build-modes
parentae5f68ba51bbbe308cc56e70e70209652c869843 (diff)
parent8d05431f0c815227ba5cd503e88b0ee531c6eeb8 (diff)
Merge branch 'preview' into image-overlay
Diffstat (limited to 'src/write/build-modes')
-rw-r--r--src/write/build-modes/live-dev-server.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index 39229a9a..a8fd3705 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -163,7 +163,15 @@ export async function go({
         localDirectory = mediaPath;
       }
 
-      const filePath = path.resolve(localDirectory, safePath.split('/').join(path.sep));
+      let filePath;
+      try {
+        filePath = path.resolve(localDirectory, decodeURI(safePath.split('/').join(path.sep)));
+      } catch (error) {
+        response.writeHead(404, contentTypePlain);
+        response.end(`No ${localFileArea} file found for: ${safePath}`);
+        console.log(`${requestHead} [404] ${pathname}`);
+        console.log(`Failed to decode request pathname`);
+      }
 
       try {
         await stat(filePath);