Skip to content

Commit

Permalink
Make querystrings more durable.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 27, 2012
1 parent de00c98 commit e454238
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Cake/Network/Http/Client.php
Expand Up @@ -188,7 +188,8 @@ public function buildUrl($url, $query = [], $options = []) {
return $url;
}
if ($query) {
$url .= '?' . http_build_query($query);
$q = (strpos($url, '?') === false) ? '?' : '&';
$url .= $q . http_build_query($query);
}
if (preg_match('#^https?://#', $url)) {
return $url;
Expand Down
7 changes: 7 additions & 0 deletions lib/Cake/Test/TestCase/Network/Http/ClientTest.php
Expand Up @@ -120,6 +120,13 @@ public static function urlProvider() {
[],
'query string data.'
],
[
'http://example.com/search?q=hi+there&id=12',
'http://example.com/search?q=hi+there',
['id' => '12'],
[],
'query string data with some already on the url.'
],
];
}

Expand Down

0 comments on commit e454238

Please sign in to comment.