Skip to content

Commit

Permalink
Apply fixes from StyleCI (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue authored Aug 16, 2019
1 parent e404d90 commit d2f13e9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/QiniuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,11 @@ protected function normalizeHost($domain)
}

/**
* Does a UTF-8 safe version of PHP parse_url function
* Does a UTF-8 safe version of PHP parse_url function.
*
* @param string $url URL to parse
* @param string $url URL to parse
*
* @return mixed Associative array or false if badly formed URL.
* @return mixed associative array or false if badly formed URL
*
* @see http://us3.php.net/manual/en/function.parse-url.php
* @since 11.1
Expand All @@ -580,7 +580,7 @@ protected static function parse_url($url)

// Build arrays of values we need to decode before parsing
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D');
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]");
$replacements = array('!', '*', "'", '(', ')', ';', ':', '@', '&', '=', '$', ',', '/', '?', '#', '[', ']');

// Create encoded URL with special URL characters decoded so it can be parsed
// All other characters will be encoded
Expand All @@ -590,13 +590,12 @@ protected static function parse_url($url)
$encodedParts = parse_url($encodedURL);

// Now, decode each value of the resulting array
if ($encodedParts)
{
foreach ($encodedParts as $key => $value)
{
if ($encodedParts) {
foreach ($encodedParts as $key => $value) {
$result[$key] = urldecode(str_replace($replacements, $entities, $value));
}
}

return $result;
}
}

0 comments on commit d2f13e9

Please sign in to comment.