From 89beb5f26470ab090fb1c49cad58d1d362262823 Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Mon, 11 Dec 2023 03:05:13 +0800 Subject: [PATCH] Fix: Handle trailing slash for status page routing (#4185) * Fix: Handle trailing slash * Chore: Add desc for default slug * Chore: Use margin instead of space * Minor --- server/model/status_page.js | 6 ++++++ src/lang/en.json | 1 + src/pages/AddStatusPage.vue | 3 +++ 3 files changed, 10 insertions(+) diff --git a/server/model/status_page.js b/server/model/status_page.js index e6095a63..06fa7a68 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -21,6 +21,12 @@ class StatusPage extends BeanModel { * @returns {void} */ static async handleStatusPageResponse(response, indexHTML, slug) { + // Handle url with trailing slash (http://localhost:3001/status/) + // The slug comes from the route "/status/:slug". If the slug is empty, express converts it to "index.html" + if (slug === "index.html") { + slug = "default"; + } + let statusPage = await R.findOne("status_page", " slug = ? ", [ slug ]); diff --git a/src/lang/en.json b/src/lang/en.json index 1cab18ce..50c2bb63 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -323,6 +323,7 @@ "Accept characters:": "Accept characters:", "startOrEndWithOnly": "Start or end with {0} only", "No consecutive dashes": "No consecutive dashes", + "statusPageSpecialSlugDesc": "Special slug {0}: this page will be shown when no slug is provided", "Next": "Next", "The slug is already taken. Please choose another slug.": "The slug is already taken. Please choose another slug.", "No Proxy": "No Proxy", diff --git a/src/pages/AddStatusPage.vue b/src/pages/AddStatusPage.vue index 4fc3f8d8..4580c98d 100644 --- a/src/pages/AddStatusPage.vue +++ b/src/pages/AddStatusPage.vue @@ -25,6 +25,9 @@ a-z 0-9
  • {{ $t("No consecutive dashes") }} --
  • + + default +