VENOM: Fix Router cannot find Route if Trailing Slash is existing (VersusTuneZ)
FIX Typos Change Folder WIP
This commit is contained in:
parent
85549fbd43
commit
196ff0b1f1
7 changed files with 24 additions and 18 deletions
|
@ -41,6 +41,7 @@ class Router
|
|||
public function findRoute($url, $method): ?array
|
||||
{
|
||||
$url = $this->removeIfFirst($url, $this->prefix);
|
||||
$url = $this->removeTrailingSlash($url);
|
||||
// check if full match... this can easily done if the url isset select the empty!
|
||||
$method = strtoupper($method);
|
||||
$route = $this->getRouteByName($url, $method);
|
||||
|
@ -64,14 +65,16 @@ class Router
|
|||
return $rawString;
|
||||
}
|
||||
|
||||
/* @todo implement Security Check if SecurityModule is used */
|
||||
private function getRouteByName($url, $method, $subRoute = '*', $params = []): ?array
|
||||
{
|
||||
$routeAvailable = isset($this->routes[$url]);
|
||||
$subRouteFound = isset($this->routes[$url]['routes'][$subRoute]);
|
||||
$methodFound = isset($this->routes[$url]['routes'][$subRoute][$method]);
|
||||
if ($routeAvailable && $subRouteFound && $methodFound) {
|
||||
if ((Config::getInstance()->getSecurity()->useSecurity || $this->id === self::ADMIN_ROUTER) && isset($this->routes[$url]['roles'])) {
|
||||
if (isset($this->routes[$url])
|
||||
&& isset($this->routes[$url]['routes'])
|
||||
&& isset($this->routes[$url]['routes'][$subRoute])
|
||||
&& isset($this->routes[$url]['routes'][$subRoute][$method])
|
||||
) {
|
||||
if ((Config::getInstance()->getSecurity()->useSecurity || $this->id === self::ADMIN_ROUTER)
|
||||
&& isset($this->routes[$url]['roles'])
|
||||
) {
|
||||
$roles = $this->routes[$url]['roles'];
|
||||
if (!in_array(User::GUEST_ROLE, $roles, true) && !Security::get()->hasRoles($roles)) {
|
||||
return null;
|
||||
|
@ -122,4 +125,10 @@ class Router
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function removeTrailingSlash(string $rawString)
|
||||
{
|
||||
$len = strlen($rawString);
|
||||
return $rawString[$len - 1] === '/' ? substr($rawString, 0, strlen($rawString) - 1) : $rawString;
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ class MetaDataModule implements Module, Route
|
|||
AdminHelper::sendResponse([
|
||||
'metaData' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class PageModule implements Module, Route
|
|||
['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'],
|
||||
['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'],
|
||||
['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit']
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,10 @@ class PageModule implements Module, Route
|
|||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
'users' => [
|
||||
['value' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['value' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ class UserModule implements Module, Route
|
|||
AdminHelper::sendResponse([
|
||||
'users' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class VenomStatusModule implements Module, Route
|
|||
AdminHelper::sendResponse([
|
||||
'users' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -13,14 +13,7 @@
|
|||
{include(includes/input;class=input-group;label=Page Name;name=PageName;error=Page Name is required;default=Turbinen sind geil)}
|
||||
</div>
|
||||
<div>
|
||||
<!--{include(includes/select;required=false;name=pageVisibility;label=Current Author)}-->
|
||||
<v-select required name="pageVisibility">
|
||||
<v-label empty="Current Author"></v-label>
|
||||
<v-options>
|
||||
<v-option value="engineertrooper">engineertrooper (Dominic Seela)</v-option>
|
||||
<v-option value="versustunez">versustunez (Maurice Grönwoldt)</v-option>
|
||||
</v-options>
|
||||
</v-select>
|
||||
{include(includes/select;name=pageVisibility;label=Current Author;object=$users)}
|
||||
</div>
|
||||
<div>
|
||||
<v-select required name="pageVisibility">
|
||||
|
|
Loading…
Reference in a new issue