mirror of
https://github.com/friendica/friendica
synced 2025-04-26 01:10:15 +00:00
Create own base URL class which holds the whole base url business logic
This commit is contained in:
parent
6ea531d2f8
commit
318a3ca785
16 changed files with 434 additions and 876 deletions
|
@ -835,4 +835,26 @@ class Network
|
|||
(strlen($query) ? "?".$query : '') .
|
||||
(strlen($fragment) ? "#".$fragment : '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Switch the scheme of an url between http and https
|
||||
*
|
||||
* @param string $url URL
|
||||
*
|
||||
* @return string switched URL
|
||||
*/
|
||||
public static function switchScheme($url)
|
||||
{
|
||||
$parts = parse_url($url, PHP_URL_SCHEME);
|
||||
if (!isset($parts['scheme'])) {
|
||||
return $url;
|
||||
}
|
||||
if ($parts['scheme'] == 'http') {
|
||||
$url = str_replace('http://', 'https://', $url);
|
||||
} elseif ($parts['scheme'] == 'https') {
|
||||
$url = str_replace('https://', 'http://', $url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue