Skip to content

Commit 3f4bfda

Browse files
committed
fix: clear phar mark error on has point char
1 parent c93173f commit 3f4bfda

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/FileSystem.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,27 @@ public static function pathFormat(string $dirName): string
8686
}
8787

8888
/**
89-
* @param string $path e.g phar://E:/workenv/xxx/yyy/app.phar/web
89+
* @param string $path
9090
*
9191
* @return string
9292
*/
9393
public static function clearPharPath(string $path): string
94+
{
95+
return self::clearPharMark($path);
96+
}
97+
98+
/**
99+
* @param string $path e.g 'phar://E:/workenv/xxx/yyy/app.phar/web' -> 'E:/workenv/xxx/yyy/web'
100+
*
101+
* @return string
102+
*/
103+
public static function clearPharMark(string $path): string
94104
{
95105
if (strpos($path, 'phar://') === 0) {
96106
$path = (string)substr($path, 7);
97107

98108
if (strpos($path, '.phar') > 0) {
99-
return preg_replace('/\/[\w-]+\.phar/', '', $path);
109+
return preg_replace('/\/[\w\.-]+\.phar/', '', $path);
100110
}
101111
}
102112

test/FsTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function testClearPharPath(): void
3333
['phar:///workenv/xxx/yyy/app.phar/web', '/workenv/xxx/yyy/web'],
3434
['E:/workenv/xxx/yyy/web', 'E:/workenv/xxx/yyy/web'],
3535
['/workenv/xxx/yyy/web', '/workenv/xxx/yyy/web'],
36+
['phar:///home/runner/kite/kite-v1.1.8.phar/config/config.php', '/home/runner/kite/config/config.php'],
3637
];
3738

3839
foreach ($tests as [$test, $want]) {

0 commit comments

Comments
 (0)