diff --git a/src/Glob.php b/src/Glob.php index f1fa126..019d2bf 100644 --- a/src/Glob.php +++ b/src/Glob.php @@ -270,6 +270,11 @@ public static function getBasePath($glob, $flags = 0) return substr($staticPrefix, 0, $pos + 1); } + // If the prefix is a no-path custom stream, that's a valid base path. + if ($pos - 2 === strrpos($staticPrefix, '://')) { + return $staticPrefix; + } + return substr($staticPrefix, 0, $pos); } diff --git a/src/Path.php b/src/Path.php index faead48..073f2c6 100644 --- a/src/Path.php +++ b/src/Path.php @@ -46,7 +46,7 @@ public static function isAbsolute(string $path): bool } // UNIX root "/" or "\" (Windows style) - if ('/' === $path[0] || '\\' === $path[0]) { + if ($path === '' || '/' === $path[0] || '\\' === $path[0]) { return true; } diff --git a/tests/GlobTest.php b/tests/GlobTest.php index 07eb1d6..8708d64 100644 --- a/tests/GlobTest.php +++ b/tests/GlobTest.php @@ -769,7 +769,7 @@ public function testGetBasePath($glob, $basePath, $flags = 0) } /** - * @dataProvider provideBasePaths + * @dataProvider provideBasePathsStream */ public function testGetBasePathStream($glob, $basePath) { @@ -793,6 +793,12 @@ public function provideBasePaths() ); } + public function provideBasePathsStream() + { + yield from $this->provideBasePaths(); + yield ['', '']; + } + public function testGetBasePathFailsIfNotAbsolute() { $this->expectException(\InvalidArgumentException::class);