X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FNetwork.php;h=e4e9c5af5bb5a75673017425b6cc298057fa74ac;hb=eef85584c20121ed01b64401ac51ed279d19db8b;hp=cda8c9a71d7113ddb0812af350195943425cf6d8;hpb=4375edd63e44b71913bd45bf25a4a554582b581e;p=friendica.git diff --git a/src/Util/Network.php b/src/Util/Network.php index cda8c9a71d..e4e9c5af5b 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -459,7 +459,6 @@ class Network * @param string $url The url to check the domain from * * @return boolean - * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function isUrlBlocked($url) { @@ -836,4 +835,28 @@ class Network (strlen($query) ? "?".$query : '') . (strlen($fragment) ? "#".$fragment : ''); } + + + /** + * Switch the scheme of an url between http and https + * + * @param string $url URL + * + * @return string switched URL + */ + public static function switchScheme($url) + { + $scheme = parse_url($url, PHP_URL_SCHEME); + if (empty($scheme)) { + return $url; + } + + if ($scheme === 'http') { + $url = str_replace('http://', 'https://', $url); + } elseif ($scheme === 'https') { + $url = str_replace('https://', 'http://', $url); + } + + return $url; + } }