refactor: isolate mock runtime from production webapp

This commit is contained in:
3252a8
2026-05-27 23:56:37 +03:00
parent b6c6887842
commit 1620de9a01
2 changed files with 59 additions and 20 deletions
+8 -2
View File
@@ -18,6 +18,13 @@ export function normalizeSection(value) {
return "home";
}
export function normalizeAdminSection(value) {
const section = String(value || "")
.trim()
.toLowerCase();
return ADMIN_SECTIONS.has(section) ? section : "stats";
}
export function sectionFromPath(pathname) {
const normalizedPath = String(pathname || "")
.trim()
@@ -43,8 +50,7 @@ export function adminSectionFromPath(pathname) {
.toLowerCase()
.replace(/\/+$/, "");
const m = normalized.match(/^\/admin\/([a-z0-9_-]+)(?:\/.*)?$/);
if (m && ADMIN_SECTIONS.has(m[1])) return m[1];
return "stats";
return normalizeAdminSection(m ? m[1] : "");
}
export function adminUserIdFromPath(pathname) {