summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/ucode/dispatcher.uc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/ucode/dispatcher.uc')
-rw-r--r--modules/luci-base/ucode/dispatcher.uc23
1 files changed, 14 insertions, 9 deletions
diff --git a/modules/luci-base/ucode/dispatcher.uc b/modules/luci-base/ucode/dispatcher.uc
index 39af8375ea..8717385be2 100644
--- a/modules/luci-base/ucode/dispatcher.uc
+++ b/modules/luci-base/ucode/dispatcher.uc
@@ -52,7 +52,7 @@ function error500(msg, ex) {
}
catch {
http.write('<!--]]>--><!--\'>--><!--">-->\n');
- http.write(`<p>${trim(ex)}</p>\n`);
+ http.write(`<p>${trim(msg)}</p>\n`);
if (ex) {
http.write(`<p>${trim(ex.message)}</p>\n`);
@@ -395,7 +395,7 @@ function build_pagetree() {
}
node.children ??= {};
- node.children[s[0]] ??= {};
+ node.children[s[0]] ??= { satisfied: true };
node = node.children[s[0]];
}
@@ -772,7 +772,7 @@ function render_action(fn) {
}
function run_action(request_path, lang, tree, resolved, action) {
- switch (action?.type) {
+ switch ((type(action) == 'object') ? action.type : 'none') {
case 'template':
if (runtime.is_ucode_template(action.path))
runtime.render(action.path, {});
@@ -840,14 +840,19 @@ function run_action(request_path, lang, tree, resolved, action) {
break;
case 'firstchild':
- if (!length(tree.children))
+ if (!length(tree.children)) {
error404("No root node was registered, this usually happens if no module was installed.\n" +
"Install luci-mod-admin-full and retry. " +
"If the module is already installed, try removing the /tmp/luci-indexcache file.");
- else
- error404(`No page is registered at '/${entityencode(join("/", resolved.ctx.request_path))}'.\n` +
- "If this url belongs to an extension, make sure it is properly installed.\n" +
- "If the extension was recently installed, try removing the /tmp/luci-indexcache file.");
+ break;
+ }
+
+ /* fall through */
+
+ case 'none':
+ error404(`No page is registered at '/${entityencode(join("/", resolved.ctx.request_path))}'.\n` +
+ "If this url belongs to an extension, make sure it is properly installed.\n" +
+ "If the extension was recently installed, try removing the /tmp/luci-indexcache file.");
break;
default:
@@ -886,7 +891,7 @@ dispatch = function(_http, path) {
striptags,
entityencode,
_: (...args) => translate(...args) ?? args[0],
- N_: (...args) => ntranslate(...args) ?? (n[0] == 1 ? n[1] : n[2]),
+ N_: (...args) => ntranslate(...args) ?? (args[0] == 1 ? args[1] : args[2]),
});
try {