mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 03:22:39 +00:00
Fixed bug where Dispatcher::getUrl() returned incorrect URL if $base appeared in a $uri besides at start of $uri.
This commit is contained in:
parent
d5fb0b25cb
commit
b567de977e
2 changed files with 18 additions and 11 deletions
|
@ -483,8 +483,8 @@ class Dispatcher extends Object {
|
|||
if ($tmpUri === '/' || $tmpUri == $baseDir || $tmpUri == $base) {
|
||||
$url = $_GET['url'] = '/';
|
||||
} else {
|
||||
if ($base && strpos($uri, $base) !== false) {
|
||||
$elements = explode($base, $uri);
|
||||
if ($base && strpos($uri, $base) === 0) {
|
||||
$elements = explode($base, $uri, 2);
|
||||
} elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) {
|
||||
$elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri));
|
||||
} else {
|
||||
|
|
|
@ -1017,6 +1017,13 @@ class DispatcherTest extends CakeTestCase {
|
|||
$expected = '?/home';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$_GET['url'] = array();
|
||||
$Dispatcher =& new Dispatcher();
|
||||
$Dispatcher->base = '/shop';
|
||||
$uri = '/shop/fr/pages/shop';
|
||||
$result = $Dispatcher->getUrl($uri);
|
||||
$expected = 'fr/pages/shop';
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue