Skip to content

Commit

Permalink
bug fix in Router.php
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfaramarzi committed Aug 27, 2021
1 parent b386776 commit 30387bb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ protected function addRoute(string $method , string $route , array $callback): v
if (strcmp($firstChar , '/') === 0)
$route = substr($route , 1);

$lastChar = substr($this->currentGroupPrefix , -1);
if (strcmp($lastChar , '/') === 0)
$prefixLastChar = substr($this->currentGroupPrefix , -1);
if (strcmp($prefixLastChar , '/') === 0)
$route = $this->currentGroupPrefix . $route;
else
$route = $this->currentGroupPrefix . '/' . $route;

$routeLastChar = substr($route, -1);
if (strcmp($routeLastChar , '/') === 0)
$route = substr($route, 0 ,-1);

if (isset($callback['middleware']) && is_array($callback['middleware']))
array_push($this->currentGroupMiddleware , ...$callback['middleware']);

Expand Down

0 comments on commit 30387bb

Please sign in to comment.