Skip to content

Commit

Permalink
misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anlutro committed Apr 1, 2015
1 parent b1cc317 commit cfadc6b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
/vendor
composer.phar
composer.lock
.DS_Store
.idea

/composer.lock
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- hhvm-nightly

matrix:
allow_failures:
- php: hhvm
- php: hhvm-nightly
- php: 7.0

install: composer install --dev --prefer-dist

Expand Down
28 changes: 12 additions & 16 deletions src/cURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,36 +106,32 @@ public function setResponseClass($class)
*/
public function buildUrl($url, array $query)
{
// append the query string
if (empty($query)) {
return $url;
}

$coms = parse_url($url);
$queryString = "";
if (isset($coms["query"]) && strlen($coms["query"])) {
$queryString .= $coms["query"] . "&" . http_build_query($query);
}
else {
$parts = parse_url($url);

$queryString = '';
if (isset($parts['query']) && $parts['query']) {
$queryString .= $parts['query'].'&'.http_build_query($query);
} else {
$queryString .= http_build_query($query);
}

$retUrl = $coms["scheme"] . "://" . $coms["host"];
if (isset($coms["port"])) {
$retUrl .= ":" . $coms["port"];
$retUrl = $parts['scheme'].'://'.$parts['host'];
if (isset($parts['port'])) {
$retUrl .= ':'.$parts['port'];
}

if (isset($coms["path"])) {
$retUrl .= $coms["path"];
if (isset($parts['path'])) {
$retUrl .= $parts['path'];
}

if ($queryString) {
$retUrl .= "?" . $queryString;
$retUrl .= '?' . $queryString;
}

if (isset($coms["fragment"])) {
$retUrl .= "#" . $coms["fragment"];
}
return $retUrl;
}

Expand Down

0 comments on commit cfadc6b

Please sign in to comment.