Skip to content

Commit

Permalink
small correction in regex
Browse files Browse the repository at this point in the history
  • Loading branch information
mbed67 committed Aug 16, 2015
1 parent 0a99d5b commit abe889a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Specification/InPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function isSatisfiedBy(array $value)
$validChars = '[a-zA-Z0-9\\\/\.\<\>\,\|\:\(\)\&\;\#]';

$pattern = '(^(?!\/)'
. str_replace(['?', '*'], [$validChars . '?', $validChars . '*'], $path)
. str_replace(['?', '*'], [$validChars . '{1}', $validChars . '*'], $path)
. $validChars . '*)';

if (preg_match($pattern, $value['dirname'] . '/')) {
Expand Down
11 changes: 7 additions & 4 deletions tests/unit/Specification/InPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ public function validDirnames()
['.hiddendir/n'],
['.hiddendir/n/'],
['.hiddendir/n/somedir'],
['.hiddendir/n/somedir.txt']
['.hiddendir/n/somedir.txt'],
['ddenxir/n']
];
}

/**
* @covers ::__construct
* @covers ::isSatisfiedBy
* @covers ::<private>
* @dataProvider InvalidDirnames
* @dataProvider invalidDirnames
* @uses Flyfinder\Path
*/
public function testIfSpecificationIsNotSatisfied($dirname)
Expand All @@ -76,12 +77,14 @@ public function testIfSpecificationIsNotSatisfied($dirname)
*
* @return array
*/
public function InvalidDirnames()
public function invalidDirnames()
{
return [
['/hiddendir/n'],
['.hiddendir/normaldir'],
['.hiddendir.ext/n']
['.hiddendir.ext/n'],
['.hiddenxxir/n'],
['.hiddenir/n']
];
}
}

0 comments on commit abe889a

Please sign in to comment.