Fix parameter issue with route_to. Fixes #992

This commit is contained in:
Lonnie Ezell 2018-04-20 22:34:29 -05:00
parent 74e95d35ed
commit 30626e853c
No known key found for this signature in database
GPG Key ID: 8EB408F8D82F5002
2 changed files with 15 additions and 1 deletions

View File

@ -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
{

View File

@ -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();