Skip to content

Commit

Permalink
fix: slug input (#5239)
Browse files Browse the repository at this point in the history
Co-authored-by: Frank Elsinga <frank@elsinga.de>
  • Loading branch information
Zoobdude and CommanderStorm authored Nov 26, 2024
1 parent 4228dd0 commit cdb8ad3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion server/routers/status-page-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ const server = UptimeKumaServer.getInstance();

router.get("/status/:slug", cache("5 minutes"), async (request, response) => {
let slug = request.params.slug;
slug = slug.toLowerCase();
await StatusPage.handleStatusPageResponse(response, server.indexHTML, slug);
});

router.get("/status/:slug/rss", cache("5 minutes"), async (request, response) => {
let slug = request.params.slug;
slug = slug.toLowerCase();
await StatusPage.handleStatusPageRSSResponse(response, slug);
});

Expand All @@ -37,6 +39,7 @@ router.get("/status-page", cache("5 minutes"), async (request, response) => {
router.get("/api/status-page/:slug", cache("5 minutes"), async (request, response) => {
allowDevAllOrigin(response);
let slug = request.params.slug;
slug = slug.toLowerCase();

try {
// Get Status Page
Expand Down Expand Up @@ -69,6 +72,7 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
let uptimeList = {};

let slug = request.params.slug;
slug = slug.toLowerCase();
let statusPageID = await StatusPage.slugToID(slug);

let monitorIDList = await R.getCol(`
Expand Down Expand Up @@ -111,6 +115,7 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
router.get("/api/status-page/:slug/manifest.json", cache("1440 minutes"), async (request, response) => {
allowDevAllOrigin(response);
let slug = request.params.slug;
slug = slug.toLowerCase();

try {
// Get Status Page
Expand Down Expand Up @@ -145,7 +150,8 @@ router.get("/api/status-page/:slug/manifest.json", cache("1440 minutes"), async
// overall status-page status badge
router.get("/api/status-page/:slug/badge", cache("5 minutes"), async (request, response) => {
allowDevAllOrigin(response);
const slug = request.params.slug;
let slug = request.params.slug;
slug = slug.toLowerCase();
const statusPageID = await StatusPage.slugToID(slug);
const {
label,
Expand Down
1 change: 1 addition & 0 deletions server/socket-handlers/status-page-socket-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ module.exports.statusPageSocketHandler = (socket) => {
ok: true,
msg: "successAdded",
msgi18n: true,
slug: slug
});

} catch (error) {
Expand Down
11 changes: 6 additions & 5 deletions src/pages/AddStatusPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
<label for="slug" class="form-label">{{ $t("Slug") }}</label>
<div class="input-group">
<span id="basic-addon3" class="input-group-text">/status/</span>
<input id="slug" v-model="slug" type="text" class="form-control" required data-testid="slug-input">
<input id="slug" v-model="slug" type="text" class="form-control" autocapitalize="none" required data-testid="slug-input">
</div>
<div class="form-text">
<ul>
<li>{{ $t("Accept characters:") }} <mark>a-z</mark> <mark>0-9</mark> <mark>-</mark></li>
<i18n-t tag="li" keypath="startOrEndWithOnly">
<mark>a-z</mark> <mark>0-9</mark>
</i18n-t>
<li>{{ $t("No consecutive dashes") }} <mark>--</mark></li>
<i18n-t tag="li" keypath="statusPageSpecialSlugDesc">
<mark class="me-1">default</mark>
Expand Down Expand Up @@ -65,7 +62,7 @@ export default {
this.processing = false;
if (res.ok) {
location.href = "/status/" + this.slug + "?edit";
location.href = "/status/" + res.slug + "?edit";
} else {
if (res.msg.includes("UNIQUE constraint")) {
Expand All @@ -85,4 +82,8 @@ export default {
.shadow-box {
padding: 20px;
}
#slug {
text-transform: lowercase;
}
</style>

0 comments on commit cdb8ad3

Please sign in to comment.