Skip to content

feat(router): allow checking an action against the current route#1059

Merged
innocenzi merged 4 commits intotempestphp:mainfrom
innocenzi:feat/is-current-uri
Mar 25, 2025
Merged

feat(router): allow checking an action against the current route#1059
innocenzi merged 4 commits intotempestphp:mainfrom
innocenzi:feat/is-current-uri

Conversation

@innocenzi
Copy link
Member

@innocenzi innocenzi commented Mar 22, 2025

This pull request adds the ability to check whether the current route matches the specified controller action:

// /user/1

Tempest\is_uri(UserController::class); // true
Tempest\is_uri(UserController::class, id: 1); // true
Tempest\is_uri(UserController::class, id: 2); // false

$router->isCurrentUri(UserController::class); // true
$router->isCurrentUri(UserController::class, id: 1); // true
$router->isCurrentUri(UserController::class, id: 2); // false

Note that this doesn't currently apply the regular expression constraint for a given parameter, allowing to match an invalid parameter against the current route (which should never happen, since the route would not have matched in the first place)

@innocenzi innocenzi force-pushed the feat/is-current-uri branch from 3bfa653 to 7119cac Compare March 23, 2025 17:49
@innocenzi innocenzi merged commit a8b6ea9 into tempestphp:main Mar 25, 2025
65 checks passed
@innocenzi innocenzi deleted the feat/is-current-uri branch March 25, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants