public static function createFromWindowsPath(string $uri = ''): self
    {
        $root = '';
        if (1 === preg_match(self::REGEXP_WINDOW_PATH, $uri, $matches)) {
            $root = substr($matches['root'], 0, -1).':';
            $uri = substr($uri, strlen($root));
        }
        $uri = str_replace('\\', '/', $uri);
        $uri = implode('/', array_map('rawurlencode', explode('/', $uri)));

        //Local Windows absolute path
        if ('' !== $root) {
            return Uri::createFromComponents(['path' => '/'.$root.$uri, 'scheme' => 'file', 'host' => '']);
        }

        //UNC Windows Path
        if ('//' !== substr($uri, 0, 2)) {
            return Uri::createFromComponents(['path' => $uri]);
        }

        $parts = explode('/', substr($uri, 2), 2) + [1 => null];

        return Uri::createFromComponents(['host' => $parts[0], 'path' => '/'.$parts[1], 'scheme' => 'file']);
    }
public static function createFromWindowsPath(string $uri = ''): self
    {
        $root = '';
        if (1 === preg_match(self::REGEXP_WINDOW_PATH, $uri, $matches)) {
            $root = substr($matches['root'], 0, -1).':';
            $uri = substr($uri, strlen($root));
        }
        $uri = str_replace('\\', '/', $uri);
        $uri = implode('/', array_map('rawurlencode', explode('/', $uri)));

        //Local Windows absolute path
        if ('' !== $root) {
            return Uri::createFromComponents(['path' => '/'.$root.$uri, 'scheme' => 'file', 'host' => '']);
        }

        //UNC Windows Path
        if ('//' !== substr($uri, 0, 2)) {
            return Uri::createFromComponents(['path' => $uri]);
        }

        $parts = explode('/', substr($uri, 2), 2) + [1 => null];

        return Uri::createFromComponents(['host' => $parts[0], 'path' => '/'.$parts[1], 'scheme' => 'file']);
    }
public static function createFromWindowsPath ( string $ uri = '' ) : self { $ root = '' ; if ( 1 === preg_match ( self :: REGEXP_WINDOW_PATH , $ uri , $ matches ) ) { $ root = substr ( $ matches [ 'root' ] , 0 , - 1 ) . ':' ; $ uri = substr ( $ uri , strlen ( $ root ) ) ; } $ uri = str_replace ( '\\' , '/' , $ uri ) ; $ uri = implode ( '/' , array_map ( 'rawurlencode' , explode ( '/' , $ uri ) ) ) ; //Local Windows absolute path if ( '' !== $ root ) { return Uri :: createFromComponents ( [ 'path' => '/' . $ root . $ uri , 'scheme' => 'file' , 'host' => '' ] ) ; } //UNC Windows Path if ( '//' !== substr ( $ uri , 0 , 2 ) ) { return Uri :: createFromComponents ( [ 'path' => $ uri ] ) ; } $ parts = explode ( '/' , substr ( $ uri , 2 ) , 2 ) + [ 1 => null ] ; return Uri :: createFromComponents ( [ 'host' => $ parts [ 0 ] , 'path' => '/' . $ parts [ 1 ] , 'scheme' => 'file' ] ) ; }
Create a new instance from a local Windows path string.
Create a new instance from a local Windows path string .