src/Util/U.php
public static function get_base_url($url) {
        $pieces = parse_url($url);
        $retval = $pieces['scheme'].'://'.$pieces['host'];
        $port = self::get($pieces,'port');
        if ( $port && $port != 80 && $port != 443 ) $retval .= ':' . $port;
        return $retval;
    }
public static function get_base_url($url) {
        $pieces = parse_url($url);
        $retval = $pieces['scheme'].'://'.$pieces['host'];
        $port = self::get($pieces,'port');
        if ( $port && $port != 80 && $port != 443 ) $retval .= ':' . $port;
        return $retval;
    }
public static function get_base_url ( $ url ) { $ pieces = parse_url ( $ url ) ; $ retval = $ pieces [ 'scheme' ] . '://' . $ pieces [ 'host' ] ; $ port = self :: get ( $ pieces , 'port' ) ; if ( $ port && $ port != 80 && $ port != 443 ) $ retval .= ':' . $ port ; return $ retval ; }
Get the protocol, host, and port from an absolute URL

input: http://localhost:8888/tsugi
output: http://localhost:8888
Get the protocol host and port from an absolute URL