From 5b4d15dc3b695e789c4ab5b5e9b4e94be307cf84 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 28 Nov 2009 21:54:33 -0500 Subject: [PATCH] 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. --- cake/libs/router.php | 4 ++-- cake/tests/cases/libs/router.test.php | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 8194dcb6a..1a3312c81 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1280,8 +1280,8 @@ class RouterRoute { } $names[] = $name; } - if (preg_match('#\/\*#', $route, $m)) { - $parsed = preg_replace('#/\\\\\*#', '(?:/(?P<_args_>.*))?', $parsed); + if (preg_match('#\/\*$#', $route, $m)) { + $parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed); } $parsed = str_replace($search, $replacements, $parsed); $this->_compiledRoute = '#^' . $parsed . '[/]*$#'; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index f3e5fcd6c..a472121dd 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1646,20 +1646,11 @@ class RouterTest extends CakeTestCase { Router::reload(); 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('/'); $expected = array('pass' => array('home'), 'named' => array(), '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/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'); $expected = array('pass' => array('home'), 'named' => array('event' => 'value'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); $this->assertEqual($result, $expected); @@ -2110,16 +2101,6 @@ class RouterRouteTestCase extends CakeTestCase { function testComplexRouteCompilingAndParsing() { 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( '/posts/:month/:day/:year/*', array('controller' => 'posts', 'action' => 'view'), array('year' => $Year, 'month' => $Month, 'day' => $Day)