thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

Url resolve fails with 2 numeric parameter #315

Closed ghost closed 3 weeks ago

ghost commented 3 years ago

/test/{id:\d+}/test/{domainId:\d+}/delete

see PR #314 for a failing test

kkFelix commented 2 years ago

Any news on this? It also fails when any first parameter contains any regex.

$route = new Route('GET', '/date/{year:\d+}/{month}', static function () { });
$path = $route->getPath([
    'year' => 2000,
    'month' => 1
]); // returns just "date/2000"

This is especially unfortunate if you want to use localized urls like this:

$route = new Route('GET', '/lang/{lang:(?:de|en))}/test/{foo}', static function () { });
$path = $route->getPath([
    'lang' => 'en',
    'foo' => 42
]); // returns just "lang/en"
philipobenito commented 2 years ago

Sorry for the delay, been dealing with some health issues.

Planning a merge/release session next week so will sort then.

switchplane-tom commented 1 year ago

Do you have any update on this issue at all? It seems to be caused when there is more than one wildcard with a matcher.

$route = new \League\Route\Route('GET', '/a/{wildcard}/and/{wildcardWithMatcher:uuid}/and/{anotherWildcardWithMatcher:uuid}', static function () {
});
$path = $route->getPath([
    'wildcard'            => 'replaced-wildcard',
    'wildcardWithMatcher' => 'replaced-wildcard-with-matcher',
    'anotherWildcardWithMatcher' => 'replaced-another-wildcard-with-matcher'
]); // returns just "/a/replaced-wildcard/and/replaced-wildcard-with-matcher"
philipobenito commented 3 weeks ago

Merged #333, a tag on 5.x will arrive early next week and will be merged in to 6.x branch too