updating dispatcher related to #3856, test added

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6408 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-01-24 21:19:13 +00:00
parent f598b58465
commit ebeb7d0f94
2 changed files with 9 additions and 1 deletions

View file

@ -605,7 +605,7 @@ class Dispatcher extends Object {
if ($tmpUri === '/' || $tmpUri == $baseDir || $tmpUri == $base) {
$url = $_GET['url'] = '/';
} else {
if (strpos($uri, $base) !== false) {
if ($base && strpos($uri, $base) !== false) {
$elements = explode($base, $uri);
} elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) {
$elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri));

View file

@ -372,6 +372,14 @@ class DispatcherTest extends UnitTestCase {
$result = $Dispatcher->getUrl($uri);
$expected = 'students/browse';
$this->assertEqual($expected, $result);
$_GET['url'] = array();
$Dispatcher =& new Dispatcher();
$Dispatcher->base = '';
$uri = '/?/home';
$result = $Dispatcher->getUrl($uri);
$expected = '?/home';
$this->assertEqual($expected, $result);
}
function testBaseUrlAndWebrootWithModRewrite() {