normalize_url() public method

public normalize_url ( $url )
Ejemplo n.º 1
0
 public static function fix_protocol($url, $http = 1)
 {
     $url = SimplePie_Misc::normalize_url($url);
     $parsed = SimplePie_Misc::parse_url($url);
     if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') {
         return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
     }
     if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) {
         return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
     }
     if ($http === 2 && $parsed['scheme'] !== '') {
         return "feed:{$url}";
     } elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') {
         return substr_replace($url, 'podcast', 0, 4);
     } elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') {
         return substr_replace($url, 'itpc', 0, 4);
     } else {
         return $url;
     }
 }
Ejemplo n.º 2
0
 function fix_protocol($url, $http = 1)
 {
     $url = SimplePie_Misc::normalize_url($url);
     $parsed = SimplePie_Misc::parse_url($url);
     if (!empty($parsed['scheme']) && !preg_match('/^http(s)?$/i', $parsed['scheme'])) {
         return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
     }
     if (!file_exists($url) && empty($parsed['scheme'])) {
         return SimplePie_Misc::fix_protocol("http://{$url}", $http);
     }
     if ($http == 2 && !empty($parsed['scheme'])) {
         return "feed:{$url}";
     } elseif ($http == 3 && strtolower($parsed['scheme']) == 'http') {
         return substr_replace($url, 'podcast', 0, 4);
     } elseif ($http == 4 && strtolower($parsed['scheme']) == 'http') {
         return substr_replace($url, 'itpc', 0, 4);
     } else {
         return $url;
     }
 }