From abd4773e16b1c2e4a076ffdbda89e6228312e55e Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Sun, 8 Aug 2021 20:29:34 +0200 Subject: [PATCH] fix: add support of module name aliases in the router --- index.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index b637648..93e52e6 100644 --- a/index.php +++ b/index.php @@ -29,11 +29,13 @@ function generateHelp($selectedModule) { $modules = $config['modules']; $selectedModule = null; -foreach ($modules as $key => $module) { - if (strpos($_SERVER['HTTP_HOST'], $key . '.') === 0) { - $selectedModule = $module; - $selectedModule['key'] = $key; - break; +foreach ($modules as $moduleName => $module) { + foreach (array_merge([$moduleName], $module['alias'] ?? []) as $alias) { + if (strpos($_SERVER['HTTP_HOST'], $alias . '.') === 0) { + $selectedModule = $module; + $selectedModule['key'] = $moduleName; + break; + } } }