mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Fix parameter issue with route_to. Fixes #992
This commit is contained in:
parent
74e95d35ed
commit
30626e853c
@ -1129,9 +1129,11 @@ class RouteCollection implements RouteCollectionInterface
|
||||
{
|
||||
// Ensure that the param we're inserting matches
|
||||
// the expected param type.
|
||||
$pos = strpos($from, $pattern);
|
||||
|
||||
if (preg_match("|{$pattern}|", $params[$index]))
|
||||
{
|
||||
$from = str_replace($pattern, $params[$index], $from);
|
||||
$from = substr_replace($from, $params[$index], $pos, strlen($pattern));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -707,6 +707,18 @@ class RouteCollectionTest extends \CIUnitTestCase
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
public function testReverseRouteMatching()
|
||||
{
|
||||
$routes = $this->getCollector();
|
||||
|
||||
$routes->get('test/(:segment)/(:segment)', 'TestController::test/$1/$2', ['as' => 'testRouter']);
|
||||
|
||||
$match = $routes->reverseRoute('testRouter', 1, 2);
|
||||
|
||||
$this->assertEquals('/test/1/2', $match);
|
||||
}
|
||||
|
||||
|
||||
public function testAddRedirect()
|
||||
{
|
||||
$routes = $this->getCollector();
|
||||
|
Loading…
x
Reference in New Issue
Block a user