src/AbstractUrl.php
protected static function formatPathComponent(array $components, $url)
    {
        if (is_null($components['scheme'])
            && is_null($components['host'])
            && !empty($components['path'])
        ) {
            if (0 === strpos($components['path'], '///')) {
                //even with the added scheme the URL is still broken
                throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $url));
            }

            if (0 === strpos($components['path'], '//')) {
                $tmp = substr($components['path'], 2);
                $components['path'] = null;
                $res = explode('/', $tmp, 2);
                $components['host'] = $res[0];
                if (isset($res[1])) {
                    $components['path'] = $res[1];
                }
                $components = self::formatHostComponent($components);
            }
        }

        return $components;
    }
protected static function formatPathComponent(array $components, $url)
    {
        if (is_null($components['scheme'])
            && is_null($components['host'])
            && !empty($components['path'])
        ) {
            if (0 === strpos($components['path'], '///')) {
                //even with the added scheme the URL is still broken
                throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $url));
            }

            if (0 === strpos($components['path'], '//')) {
                $tmp = substr($components['path'], 2);
                $components['path'] = null;
                $res = explode('/', $tmp, 2);
                $components['host'] = $res[0];
                if (isset($res[1])) {
                    $components['path'] = $res[1];
                }
                $components = self::formatHostComponent($components);
            }
        }

        return $components;
    }
protected static function formatPathComponent ( array $ components , $ url ) { if ( is_null ( $ components [ 'scheme' ] ) && is_null ( $ components [ 'host' ] ) && ! empty ( $ components [ 'path' ] ) ) { if ( 0 === strpos ( $ components [ 'path' ] , '///' ) ) { //even with the added scheme the URL is still broken throw new RuntimeException ( sprintf ( 'The given URL: `%s` could not be parse' , $ url ) ) ; } if ( 0 === strpos ( $ components [ 'path' ] , '//' ) ) { $ tmp = substr ( $ components [ 'path' ] , 2 ) ; $ components [ 'path' ] = null ; $ res = explode ( '/' , $ tmp , 2 ) ; $ components [ 'host' ] = $ res [ 0 ] ; if ( isset ( $ res [ 1 ] ) ) { $ components [ 'path' ] = $ res [ 1 ] ; } $ components = self :: formatHostComponent ( $ components ) ; } } return $ components ; }
Reformat the component according to the path content

@param array  $components the result from parse_url
@param string $url        the original URL to be parse

@return array
Reformat the component according to the path content