File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -86,17 +86,27 @@ public static function pathFormat(string $dirName): string
86
86
}
87
87
88
88
/**
89
- * @param string $path e.g phar://E:/workenv/xxx/yyy/app.phar/web
89
+ * @param string $path
90
90
*
91
91
* @return string
92
92
*/
93
93
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
94
104
{
95
105
if (strpos ($ path , 'phar:// ' ) === 0 ) {
96
106
$ path = (string )substr ($ path , 7 );
97
107
98
108
if (strpos ($ path , '.phar ' ) > 0 ) {
99
- return preg_replace ('/\/[\w-]+\.phar/ ' , '' , $ path );
109
+ return preg_replace ('/\/[\w\. -]+\.phar/ ' , '' , $ path );
100
110
}
101
111
}
102
112
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public function testClearPharPath(): void
33
33
['phar:///workenv/xxx/yyy/app.phar/web ' , '/workenv/xxx/yyy/web ' ],
34
34
['E:/workenv/xxx/yyy/web ' , 'E:/workenv/xxx/yyy/web ' ],
35
35
['/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 ' ],
36
37
];
37
38
38
39
foreach ($ tests as [$ test , $ want ]) {
You can’t perform that action at this time.
0 commit comments