Skip to content

Commit

Permalink
Revert "Improved route's priority match"
Browse files Browse the repository at this point in the history
This reverts commit 54d60dc.
  • Loading branch information
divineniiquaye committed Apr 17, 2022
1 parent c15e09c commit 31cd493
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Route.php
Expand Up @@ -46,7 +46,7 @@ class Route
*
* If route path matches, 1 is expected return else 0 should be return as priority index.
*/
public const PRIORITY_REGEX = '#^([\/\w+][^<[{:]+\b)(.*)#';
public const PRIORITY_REGEX = '#^\\/?[\\/\\w+]+\\b#';

/**
* Slashes supported on browser when used.
Expand Down
9 changes: 5 additions & 4 deletions src/Traits/DataTrait.php
Expand Up @@ -44,8 +44,8 @@ public function prefix(string $path)
$uri = \substr($uri, 1);
}

\preg_match(Route::PRIORITY_REGEX, $this->data['path'] = ('/' . \ltrim($path, '/')) . $uri, $pM);
$this->data['prefix'] = !empty($pM[1] ?? null) ? $pM[1] : null;
\preg_match(Route::PRIORITY_REGEX, $this->data['path'] = '/' . \ltrim($path . $uri, '/'), $matches);
$this->data['prefix'] = $matches[0] ?? null;
}

return $this;
Expand Down Expand Up @@ -76,10 +76,11 @@ public function path(string $pattern)
throw new UriHandlerException(\sprintf('The route pattern "%s" is invalid as route path must be present in pattern.', $pattern));
}

\preg_match(Route::PRIORITY_REGEX, $this->data['path'] = '/' . \ltrim($matches[3], '/'), $pM);
$this->data['prefix'] = !empty($pM[1] ?? null) ? $pM[1] : null;
\preg_match(Route::PRIORITY_REGEX, $matches[3], $static) && $this->data['prefix'] = $static[0];
}

$this->data['path'] = '/' . \ltrim($matches[3] ?? $pattern, '/');

return $this;
}

Expand Down

0 comments on commit 31cd493

Please sign in to comment.