Skip to content

Commit 97e0554

Browse files
committed
Allow . and ./ notation
Basically . and ./ will match just everything from a flysystem perspective since the directories are relative from the virtual filesystem.
1 parent 07aad34 commit 97e0554

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Specification/InPath.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function isSatisfiedBy(array $value)
4545
{
4646
if (isset($value['dirname'])) {
4747
$path = $this->cleanPath((string) $this->path);
48-
4948
$validChars = '[a-zA-Z0-9\\\/\.\<\>\,\|\:\(\)\&\;\#]';
5049

5150
$pattern = '(^(?!\/)'
@@ -69,6 +68,10 @@ public function isSatisfiedBy(array $value)
6968
*/
7069
private function cleanPath($path)
7170
{
71+
if ($path === '.' || $path === './') {
72+
return '';
73+
}
74+
7275
if (substr($path, 0, 2) === './') {
7376
$path = substr($path, 1);
7477
}

tests/unit/Specification/InPathTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ public function testIfSpecificationIsSatisfied($dirname)
4444
$this->assertTrue($this->fixture->isSatisfiedBy(['dirname' => $dirname]));
4545
}
4646

47+
/**
48+
* @covers ::__construct
49+
* @covers ::isSatisfiedBy
50+
* @covers ::<private>
51+
* @dataProvider validDirnames
52+
* @uses Flyfinder\Path
53+
*/
54+
public function testWithSingleDotSpec($dirname)
55+
{
56+
$spec = new InPath(new Path('.'));
57+
$this->assertTrue($spec->isSatisfiedBy(['dirname' => $dirname]));
58+
}
59+
60+
/**
61+
* @covers ::__construct
62+
* @covers ::isSatisfiedBy
63+
* @covers ::<private>
64+
* @dataProvider validDirnames
65+
* @uses Flyfinder\Path
66+
*/
67+
public function testWithCurrentDirSpec($dirname)
68+
{
69+
$spec = new InPath(new Path('./'));
70+
$this->assertTrue($spec->isSatisfiedBy(['dirname' => $dirname]));
71+
}
72+
4773
/**
4874
* Data provider for testIfSpecificationIsSatisfied. Contains a few valid directory names
4975
*

0 commit comments

Comments
 (0)