mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Removing support for mid route * elements. Mid-route lazy * behaved in a sometimes erratic fashion making routes employing mid-route lazy * hard to depend on.
This commit is contained in:
parent
33c67f7c47
commit
5b4d15dc3b
2 changed files with 2 additions and 21 deletions
|
@ -1280,8 +1280,8 @@ class RouterRoute {
|
||||||
}
|
}
|
||||||
$names[] = $name;
|
$names[] = $name;
|
||||||
}
|
}
|
||||||
if (preg_match('#\/\*#', $route, $m)) {
|
if (preg_match('#\/\*$#', $route, $m)) {
|
||||||
$parsed = preg_replace('#/\\\\\*#', '(?:/(?P<_args_>.*))?', $parsed);
|
$parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed);
|
||||||
}
|
}
|
||||||
$parsed = str_replace($search, $replacements, $parsed);
|
$parsed = str_replace($search, $replacements, $parsed);
|
||||||
$this->_compiledRoute = '#^' . $parsed . '[/]*$#';
|
$this->_compiledRoute = '#^' . $parsed . '[/]*$#';
|
||||||
|
|
|
@ -1646,20 +1646,11 @@ class RouterTest extends CakeTestCase {
|
||||||
|
|
||||||
Router::reload();
|
Router::reload();
|
||||||
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||||
Router::connect('/pages/*/:event', array('controller' => 'pages', 'action' => 'display'), array('event' => '[a-z0-9_-]+'));
|
|
||||||
|
|
||||||
$result = Router::parse('/');
|
$result = Router::parse('/');
|
||||||
$expected = array('pass' => array('home'), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
|
$expected = array('pass' => array('home'), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = Router::parse('/pages/home');
|
|
||||||
$expected = array('pass' => array('home'), 'named' => array(), 'event' => '', 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
|
|
||||||
$this->assertEqual($result, $expected);
|
|
||||||
|
|
||||||
$result = Router::parse('/pages/home/');
|
|
||||||
$expected = array('pass' => array('home'), 'named' => array(), 'event' => '', 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
|
|
||||||
$this->assertEqual($result, $expected);
|
|
||||||
|
|
||||||
$result = Router::parse('/pages/display/home/event:value');
|
$result = Router::parse('/pages/display/home/event:value');
|
||||||
$expected = array('pass' => array('home'), 'named' => array('event' => 'value'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
|
$expected = array('pass' => array('home'), 'named' => array('event' => 'value'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
@ -2110,16 +2101,6 @@ class RouterRouteTestCase extends CakeTestCase {
|
||||||
function testComplexRouteCompilingAndParsing() {
|
function testComplexRouteCompilingAndParsing() {
|
||||||
extract(Router::getNamedExpressions());
|
extract(Router::getNamedExpressions());
|
||||||
|
|
||||||
$route =& new RouterRoute(
|
|
||||||
'/pages/*/:event',
|
|
||||||
array('controller' => 'pages', 'action' => 'display'),
|
|
||||||
array('event' => '[a-z0-9_-]+')
|
|
||||||
);
|
|
||||||
$result = $route->compile();
|
|
||||||
$this->assertPattern($result, '/pages/view/today');
|
|
||||||
$this->assertPattern($result, '/pages/view/today/tomorrow');
|
|
||||||
$this->assertNoPattern($result, '/pages/view/tomorrow/something:else');
|
|
||||||
|
|
||||||
$route =& new RouterRoute(
|
$route =& new RouterRoute(
|
||||||
'/posts/:month/:day/:year/*',
|
'/posts/:month/:day/:year/*',
|
||||||
array('controller' => 'posts', 'action' => 'view'), array('year' => $Year, 'month' => $Month, 'day' => $Day)
|
array('controller' => 'posts', 'action' => 'view'), array('year' => $Year, 'month' => $Month, 'day' => $Day)
|
||||||
|
|
Loading…
Add table
Reference in a new issue