Adding tests

This commit is contained in:
Philipp Holzer 2019-04-08 23:12:34 +02:00
parent 318a3ca785
commit edd4f06ad0
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
8 changed files with 520 additions and 43 deletions

View file

@ -838,7 +838,7 @@ class Network
/**
* @brief Switch the scheme of an url between http and https
* Switch the scheme of an url between http and https
*
* @param string $url URL
*
@ -846,15 +846,17 @@ class Network
*/
public static function switchScheme($url)
{
$parts = parse_url($url, PHP_URL_SCHEME);
if (!isset($parts['scheme'])) {
$scheme = parse_url($url, PHP_URL_SCHEME);
if (empty($scheme)) {
return $url;
}
if ($parts['scheme'] == 'http') {
if ($scheme === 'http') {
$url = str_replace('http://', 'https://', $url);
} elseif ($parts['scheme'] == 'https') {
} elseif ($scheme === 'https') {
$url = str_replace('https://', 'http://', $url);
}
return $url;
}
}