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
This commit is contained in:
Nelson Chan 2023-12-11 03:05:13 +08:00 committed by GitHub
parent 65e57e5621
commit 89beb5f264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -21,6 +21,12 @@ class StatusPage extends BeanModel {
* @returns {void} * @returns {void}
*/ */
static async handleStatusPageResponse(response, indexHTML, slug) { 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 = ? ", [ let statusPage = await R.findOne("status_page", " slug = ? ", [
slug slug
]); ]);

View File

@ -323,6 +323,7 @@
"Accept characters:": "Accept characters:", "Accept characters:": "Accept characters:",
"startOrEndWithOnly": "Start or end with {0} only", "startOrEndWithOnly": "Start or end with {0} only",
"No consecutive dashes": "No consecutive dashes", "No consecutive dashes": "No consecutive dashes",
"statusPageSpecialSlugDesc": "Special slug {0}: this page will be shown when no slug is provided",
"Next": "Next", "Next": "Next",
"The slug is already taken. Please choose another slug.": "The slug is already taken. Please choose another slug.", "The slug is already taken. Please choose another slug.": "The slug is already taken. Please choose another slug.",
"No Proxy": "No Proxy", "No Proxy": "No Proxy",

View File

@ -25,6 +25,9 @@
<mark>a-z</mark> <mark>0-9</mark> <mark>a-z</mark> <mark>0-9</mark>
</i18n-t> </i18n-t>
<li>{{ $t("No consecutive dashes") }} <mark>--</mark></li> <li>{{ $t("No consecutive dashes") }} <mark>--</mark></li>
<i18n-t tag="li" keypath="statusPageSpecialSlugDesc">
<mark class="me-1">default</mark>
</i18n-t>
</ul> </ul>
</div> </div>
</div> </div>