Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add underscore support to named parameters #638

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Handlers/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ class Handler extends MiddlewareChain
* - {name}
* - {name1}
* - {firstName}
* - {first_name}
* - {n123}
* - {n}
*
* Invalid:
* - {1} (reserved for quantifiers)
* - {1,} (reserved for quantifiers)
* - {1,2} (reserved for quantifiers)
* - {1name} (must start with a letter)
* - {_1name} (must start with a letter)
*/
protected const PARAM_NAME_REGEX = '/{([a-zA-Z][a-zA-Z\d]*)}/';
protected const PARAM_NAME_REGEX = '/{([a-zA-Z][_a-zA-Z\d]*)}/';

/**
* @var string|null
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/PatternsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,11 @@ function (string $hear, string $constraint, bool $expected) {
})->with([
['name', true],
['name1', true],
['na_me1', true],
['n1255', true],
['n', true],
['1name', false],
['_1name', false],
['123e', false],
['1', false],
['1,', false],
Expand Down
Loading