Permalink
Browse files

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

  • Loading branch information...
1 parent 45a96ae commit 07735069fad116d205fd97cb539f7b6241a1e6ce Jelle Henkens committed May 9, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/Cake/Routing/Router.php
  2. +8 −0 lib/Cake/Test/Case/Routing/RouterTest.php
@@ -964,7 +964,7 @@ public static function queryString($q, $extra = array(), $escape = false) {
}
$addition = http_build_query($q, null, $join);
- if ($out && $addition) {
+ if ($out && $addition && substr($out, strlen($join) * -1, strlen($join)) != $join) {
$out .= $join;
}
@@ -2626,5 +2626,13 @@ public function testQueryString() {
$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);
}
}

0 comments on commit 0773506

Please sign in to comment.