Skip to content

Commit

Permalink
Adding support for a trailing & or & in the existing queryString
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelle Henkens authored and lorenzo committed May 11, 2012
1 parent 7a1275a commit 484c3ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -964,7 +964,7 @@ public static function queryString($q, $extra = array(), $escape = false) {
} }
$addition = http_build_query($q, null, $join); $addition = http_build_query($q, null, $join);


if ($out && $addition) { if ($out && $addition && substr($out, strlen($join) * -1, strlen($join)) != $join) {
$out .= $join; $out .= $join;
} }


Expand Down
8 changes: 8 additions & 0 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -2626,5 +2626,13 @@ public function testQueryString() {
$result = Router::queryString('foo=bar', array('php' => 'nut', 'jose' => 'zap'), true); $result = Router::queryString('foo=bar', array('php' => 'nut', 'jose' => 'zap'), true);
$expected = '?foo=bar&php=nut&jose=zap'; $expected = '?foo=bar&php=nut&jose=zap';
$this->assertEquals($expected, $result); $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);
} }
} }

0 comments on commit 484c3ec

Please sign in to comment.