Skip to content

Commit

Permalink
Merge pull request #614 from thephpleague/fix/url-encoding
Browse files Browse the repository at this point in the history
Fix encoding of generated query strings
  • Loading branch information
shadowhand committed Feb 2, 2017
2 parents a76238a + 0fae187 commit b7a3fed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Tool/QueryBuilderTrait.php
Expand Up @@ -28,6 +28,6 @@ trait QueryBuilderTrait
*/
protected function buildQueryString(array $params)
{
return http_build_query($params, null, '&');
return http_build_query($params, null, '&', \PHP_QUERY_RFC3986);
}
}
3 changes: 2 additions & 1 deletion test/src/Tool/QueryBuilderTraitTest.php
Expand Up @@ -19,10 +19,11 @@ public function testBuildQueryString()
$params = [
'a' => 'foo',
'b' => 'bar',
'c' => '+',
];

$query = $this->buildQueryString($params);

$this->assertSame('a=foo&b=bar', $query);
$this->assertSame('a=foo&b=bar&c=%2B', $query);
}
}

0 comments on commit b7a3fed

Please sign in to comment.