Skip to content

Commit

Permalink
Added URL encoding to the query parameters on build query string method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Brecht-Precht committed Jul 12, 2016
1 parent b45dd09 commit 2c4ea3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/QueryParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public function getValue()
return $this->value;
}

/**
* @return string
*/
public function getEscapedValue()
{
return urlencode((string)$this->value);
}

/**
* @param mixed $value
* @return $this
Expand Down
5 changes: 5 additions & 0 deletions src/QueryParameterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public function setKey($key);
*/
public function getValue();

/**
* @return string
*/
public function getEscapedValue();

/**
* @param mixed $value
* @return $this
Expand Down
2 changes: 1 addition & 1 deletion src/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function buildQueryString()
}
$queryParameters = array();
foreach ($this->getQueryParameters() as $queryParameter) {
$queryParameters[] = $queryParameter->getKey() . '=' . $queryParameter->getValue();
$queryParameters[] = $queryParameter->getKey() . '=' . $queryParameter->getEscapedValue();
}
return implode(self::URL_QUERY_SEPARATOR, $queryParameters);
}
Expand Down

0 comments on commit 2c4ea3d

Please sign in to comment.