]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Network.php
Fix edited messages for Diaspora
[friendica.git] / src / Util / Network.php
index 35744647e31ea742f412657e31f31e9d59c8ec18..e4e9c5af5bb5a75673017425b6cc298057fa74ac 100644 (file)
@@ -835,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;
+       }
 }