From 834fddd55e3bd9b0dfb66b71fb75b3f02cfebcf2 Mon Sep 17 00:00:00 2001 From: prplwtf Date: Fri, 22 Nov 2024 14:41:30 +0100 Subject: [PATCH] fix: allow slash at end of url --- src/components/sections/BlogSection.js | 4 ++-- src/router/Route.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/sections/BlogSection.js b/src/components/sections/BlogSection.js index 5ac4659..a433941 100644 --- a/src/components/sections/BlogSection.js +++ b/src/components/sections/BlogSection.js @@ -31,7 +31,7 @@ function BlogSection() {
${PostThumbnail}
-
+
${Post.Topic || "post"} ${Post.Content} @@ -43,7 +43,7 @@ function BlogSection() { ${Post.Description || "No description available"}
-
+
diff --git a/src/router/Route.js b/src/router/Route.js index e79523a..f1fb1cc 100644 --- a/src/router/Route.js +++ b/src/router/Route.js @@ -3,6 +3,15 @@ async function Route(view) { Unload("Section") ProgressBar(25) + // Allow URLs ending in a slash + if(view.endsWith('/')) { + let lastIndex = view.lastIndexOf('/'); + view = + view.slice(0, lastIndex) + + '' + + view.slice(lastIndex + 1); + } + // # if(view == "" || view == "#") { @@ -44,7 +53,7 @@ async function Route(view) { } // #404 - console.info(`View ${view} not found, returning 404.`) + console.warn(`404: ${view} not found.`) return Import("./src/components/sections/NotfoundSection.js", "Section", function() { App.innerHTML = `${NotfoundSection()}` ModifyAppTitle("404")