src/util/URL.php
public static function site(string $uri = '', $protocol = null): string {
        // Chop off possible scheme, host, port, user and pass parts
        $path = preg_replace('~^[-a-z0-9+.]++://[^/]++/?~', '', trim($uri, '/'));

        if (preg_match('/[^\x00-\x7F]/S', $path)) {
            // Encode all non-ASCII characters, as per RFC 1738
            $path = preg_replace_callback('~([^/]+)~', '\mii\util\URL::_rawurlencode_callback', $path);
        }

        // Concat the URL
        return URL::base($protocol) . $path;
    }
public static function site(string $uri = '', $protocol = null): string {
        // Chop off possible scheme, host, port, user and pass parts
        $path = preg_replace('~^[-a-z0-9+.]++://[^/]++/?~', '', trim($uri, '/'));

        if (preg_match('/[^\x00-\x7F]/S', $path)) {
            // Encode all non-ASCII characters, as per RFC 1738
            $path = preg_replace_callback('~([^/]+)~', '\mii\util\URL::_rawurlencode_callback', $path);
        }

        // Concat the URL
        return URL::base($protocol) . $path;
    }
Fetches an absolute site URL based on a URI segment.

echo URL::site('foo/bar');

@param   string $uri Site URI to convert
@param   mixed $protocol Protocol string or true
@return  string