Skip to content

Commit

Permalink
Allow . and ./ notation
Browse files Browse the repository at this point in the history
Basically . and ./ will match just everything from a flysystem perspective
since the directories are relative from the virtual filesystem.
  • Loading branch information
jaapio committed Dec 10, 2017
1 parent 07aad34 commit 97e0554
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Specification/InPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function isSatisfiedBy(array $value)
{
if (isset($value['dirname'])) {
$path = $this->cleanPath((string) $this->path);

$validChars = '[a-zA-Z0-9\\\/\.\<\>\,\|\:\(\)\&\;\#]';

$pattern = '(^(?!\/)'
Expand All @@ -69,6 +68,10 @@ public function isSatisfiedBy(array $value)
*/
private function cleanPath($path)
{
if ($path === '.' || $path === './') {
return '';
}

if (substr($path, 0, 2) === './') {
$path = substr($path, 1);
}
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/Specification/InPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ public function testIfSpecificationIsSatisfied($dirname)
$this->assertTrue($this->fixture->isSatisfiedBy(['dirname' => $dirname]));
}

/**
* @covers ::__construct
* @covers ::isSatisfiedBy
* @covers ::<private>
* @dataProvider validDirnames
* @uses Flyfinder\Path
*/
public function testWithSingleDotSpec($dirname)
{
$spec = new InPath(new Path('.'));
$this->assertTrue($spec->isSatisfiedBy(['dirname' => $dirname]));
}

/**
* @covers ::__construct
* @covers ::isSatisfiedBy
* @covers ::<private>
* @dataProvider validDirnames
* @uses Flyfinder\Path
*/
public function testWithCurrentDirSpec($dirname)
{
$spec = new InPath(new Path('./'));
$this->assertTrue($spec->isSatisfiedBy(['dirname' => $dirname]));
}

/**
* Data provider for testIfSpecificationIsSatisfied. Contains a few valid directory names
*
Expand Down

0 comments on commit 97e0554

Please sign in to comment.