diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 384272c1d..07b426372 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -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)); diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 915bcb2cf..6a89ade7a 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -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() {