mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
9ac5cbed36
commit
a934f700f1
2 changed files with 25 additions and 1 deletions
|
@ -518,7 +518,7 @@ class Router {
|
|||
$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 @@ class RouterTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue