Permalink
Browse files

Fix parsing '0' as a url.

Fixes #3198
  • Loading branch information...
markstory committed Sep 10, 2012
1 parent 9ac5cbe commit a934f700f1cf4b11580c98f360bbca3236bb62ac
Showing with 25 additions and 1 deletion.
  1. +1 −1 lib/Cake/Routing/Router.php
  2. +24 −0 lib/Cake/Test/Case/Routing/RouterTest.php
@@ -518,7 +518,7 @@ public static function parse($url) {
$ext = null;
$out = array();
if ($url && strpos($url, '/') !== 0) {
if (strlen($url) && strpos($url, '/') !== 0) {
$url = '/' . $url;
}
if (strpos($url, '?') !== false) {
@@ -451,6 +451,30 @@ public function testUrlGenerationBasic() {
$this->assertEquals($expected, $result);
}
/**
* Test that catch all routes work with a variety of falsey inputs.
*
* @return void
*/
public function testUrlCatchAllRoute() {
Router::connect('/*', array('controller' => 'categories', 'action' => 'index'));
$result = Router::url(array('controller' => 'categories', 'action' => 'index', '0'));
$this->assertEquals('/0', $result);
$expected = array(
'plugin' => null,
'controller' => 'categories',
'action' => 'index',
'pass' => array('0'),
'named' => array()
);
$result = Router::parse('/0');
$this->assertEquals($expected, $result);
$result = Router::parse('0');
$this->assertEquals($expected, $result);
}
/**
* Tests using arrays in named parameters
*

0 comments on commit a934f70

Please sign in to comment.