Timber\URLHelper::remove_double_slashes PHP Method

remove_double_slashes() public static method

public static remove_double_slashes ( string $url ) : string
$url string
return string
    public static function remove_double_slashes($url)
    {
        $url = str_replace('//', '/', $url);
        if (strstr($url, 'http:') && !strstr($url, 'http://')) {
            $url = str_replace('http:/', 'http://', $url);
        }
        return $url;
    }

Usage Example

示例#1
0
文件: Image.php 项目: mrgrain/timber
 /**
  * @internal
  * @param string $url
  */
 protected function init_with_url($url)
 {
     $this->abs_url = $url;
     if (URLHelper::is_local($url)) {
         $this->file = URLHelper::remove_double_slashes(ABSPATH . URLHelper::get_rel_url($url));
         $this->file_loc = URLHelper::remove_double_slashes(ABSPATH . URLHelper::get_rel_url($url));
     }
 }