fix: only treat the last path segment as a filename in path()
isFilePath() checked the entire path for a dot to decide whether path() was given a file or a directory. Because the path includes the location and name, a dot in a parent segment (for example a location like /tmp/my.app) caused a directory argument to be misclassified as a file, so the requested subdirectory was not created. Inspect only the last path segment instead.
This commit is contained in:
1 parent
539be424ae
commit
53a7d85862
3 files changed
+100
-1
No files matched your search
@@ -163,7 +163,13 @@ class TemporaryDirectory
|
||||
|
||||
protected function isFilePath(string $path): bool
|
||||
{
|
||||
return str_contains($path, '.');
|
||||
// Only the last path segment can be a filename. Inspecting the whole
|
||||
// path would misclassify a directory as a file whenever a parent
|
||||
// segment (for example the location) contains a dot.
|
||||
$lastSeparator = strrpos($path, DIRECTORY_SEPARATOR);
|
||||
$lastSegment = $lastSeparator === false ? $path : substr($path, $lastSeparator + 1);
|
||||
|
||||
return str_contains($lastSegment, '.');
|
||||
}
|
||||
|
||||
protected function deleteDirectory(string $path): bool
|
||||
|
||||
Reference in new issue
Block a user