protected function rebuildURL($url)
    {
        $defaults = $this->config['defaultparts'];
        if (!preg_match('#^[a-zA-Z]+://#', $url)) {
            $url = $defaults['scheme'] . "://" . $url;
        }
        $parts = parse_url($url);
        if (!$parts) {
            //can't parse url, abort
            return "";
        }
        foreach ($parts as $part => $value) {
            if ($this->config['removeparts'][$part] === true) {
                unset($parts[$part]);
            }
        }
        //set defaults, if missing
        foreach ($defaults as $part => $default) {
            if (!isset($parts[$part])) {
                $parts[$part] = $default;
            }
        }

        return rtrim(http_build_url($defaults, $parts), "/");
    }
protected function rebuildURL($url)
    {
        $defaults = $this->config['defaultparts'];
        if (!preg_match('#^[a-zA-Z]+://#', $url)) {
            $url = $defaults['scheme'] . "://" . $url;
        }
        $parts = parse_url($url);
        if (!$parts) {
            //can't parse url, abort
            return "";
        }
        foreach ($parts as $part => $value) {
            if ($this->config['removeparts'][$part] === true) {
                unset($parts[$part]);
            }
        }
        //set defaults, if missing
        foreach ($defaults as $part => $default) {
            if (!isset($parts[$part])) {
                $parts[$part] = $default;
            }
        }

        return rtrim(http_build_url($defaults, $parts), "/");
    }
protected function rebuildURL ( $ url ) { $ defaults = $ this -> config [ 'defaultparts' ] ; if ( ! preg_match ( '#^[a-zA-Z]+://#' , $ url ) ) { $ url = $ defaults [ 'scheme' ] . "://" . $ url ; } $ parts = parse_url ( $ url ) ; if ( ! $ parts ) { //can't parse url, abort return "" ; } foreach ( $ parts as $ part => $ value ) { if ( $ this -> config [ 'removeparts' ] [ $ part ] === true ) { unset ( $ parts [ $ part ] ) ; } } //set defaults, if missing foreach ( $ defaults as $ part => $ default ) { if ( ! isset ( $ parts [ $ part ] ) ) { $ parts [ $ part ] = $ default ; } } return rtrim ( http_build_url ( $ defaults , $ parts ) , "/" ) ; }
Add config scheme, if missing.
Remove the parts of the url we don't want.
Set any defaults, if missing.
Remove any trailing slash, and rebuild.
@return string
Add config scheme if missing . Remove the parts of the url we don t want . Set any defaults if missing . Remove any trailing slash and rebuild .