Adding support for a trailing & or & in the existing queryString

This commit is contained in:
Jelle Henkens 2012-05-09 22:32:57 +01:00 committed by Jose Lorenzo Rodriguez
parent 7a1275a1b1
commit 484c3ec688
2 changed files with 9 additions and 1 deletions

View file

@ -964,7 +964,7 @@ class Router {
}
$addition = http_build_query($q, null, $join);
if ($out && $addition) {
if ($out && $addition && substr($out, strlen($join) * -1, strlen($join)) != $join) {
$out .= $join;
}

View file

@ -2626,5 +2626,13 @@ class RouterTest extends CakeTestCase {
$result = Router::queryString('foo=bar', array('php' => 'nut', 'jose' => 'zap'), true);
$expected = '?foo=bar&php=nut&jose=zap';
$this->assertEquals($expected, $result);
$result = Router::queryString('foo=bar&', array('php' => 'nut', 'jose' => 'zap'), true);
$expected = '?foo=bar&php=nut&jose=zap';
$this->assertEquals($expected, $result);
$result = Router::queryString('foo=bar&', array('php' => 'nut', 'jose' => 'zap'));
$expected = '?foo=bar&php=nut&jose=zap';
$this->assertEquals($expected, $result);
}
}