Skip to content

Commit 4aa02ee

Browse files
committed
Fix checking to filename ADR valid
1 parent 62391d0 commit 4aa02ee

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Filesystem/Workspace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private function isValidFilename(SplFileInfo $fileinfo) : bool
145145
return false;
146146
}
147147

148-
$pattern = '/^\d{' . DecisionRecord::NUMBER_LENGTH . '}-[a-z\-]+\\' . DecisionRecord::EXTENSION . '$/';
148+
$pattern = '/^\d{' . DecisionRecord::NUMBER_LENGTH . '}-[a-z\d\-]+\\' . DecisionRecord::EXTENSION . '$/';
149149

150150
return (boolean) preg_match($pattern, $fileinfo->getFilename());
151151
}

tests/Filesystem/WorkspaceTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ public function testCount()
3636

3737
$vfs->addChild(vfsStream::newFile('0001-foo.md'));
3838
$vfs->addChild(vfsStream::newFile('0002-bar.md'));
39+
$vfs->addChild(vfsStream::newFile('0003-baz-2.md'));
40+
41+
$vfs->addChild(vfsStream::newFile('0004-snake_case.md'));
42+
$vfs->addChild(vfsStream::newFile('0005-UPPERCASE.md'));
43+
$vfs->addChild(vfsStream::newFile('0006-CamelCase.md'));
3944
$vfs->addChild(vfsStream::newFile('any-file.md'));
4045
$vfs->addChild(vfsStream::newDirectory('any-directory'));
4146

42-
$this->assertEquals(2, $workspace->count());
47+
$this->assertEquals(3, $workspace->count());
4348
}
4449

4550
public function testAdd()

0 commit comments

Comments
 (0)