Skip to content

Commit

Permalink
Fix route regex detection
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Ilic <[email protected]>
  • Loading branch information
gigili committed Mar 31, 2021
1 parent 5764c59 commit 0dd303a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function add(string $url = "", callable|string|null $callback = NULL, arr
}

$nUrl = NULL;
if (strpos($url, ":") !== false) {
if (str_contains($url, ":")) {
$nUrl = preg_replace("/(:[\w\-_]+)/", "([\w\-\_\:]+)", $url);
$nUrl = str_replace("/", "\/", $nUrl);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ public function route(): bool {

foreach ($this->routes as $route) {
if (is_null($route["regex"]) === FALSE) {
if (preg_match("/^{$route["regex"]}-{$_SERVER['REQUEST_METHOD']}/", $url) === 1) {
if (preg_match("/^{$route["regex"]}/", $url) === 1) {
$urlIndex = $route["url"];

preg_match_all("/^{$route["regex"]}-{$_SERVER['REQUEST_METHOD']}/", $url, $tmpParams);
Expand Down

0 comments on commit 0dd303a

Please sign in to comment.