Skip to content

Commit 9304e14

Browse files
author
Greg Bowler
authored
Distinct files are allowed to start with underscore (#58)
* feature: deeper dynamic pages closes #4 * build: upgrade build packages for downstream deps * tweak: phpstorm analysis * test: isolate issue #57 * feature: allow underscore files closes #57
1 parent 5ed50f3 commit 9304e14

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Assembly.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Gt\Routing;
33

44
use Countable;
5+
use Gt\Routing\Path\FileMatch\MagicFileMatch;
56
use Iterator;
67

78
/** @implements Iterator<int, string> */
@@ -36,7 +37,8 @@ public function remove(string $path):void {
3637
public function containsDistinctFile():bool {
3738
foreach($this->pathList as $path) {
3839
$fileName = pathinfo($path, PATHINFO_FILENAME);
39-
if($fileName[0] !== "_") {
40+
if(!str_starts_with($fileName, "_")
41+
|| !in_array($fileName, MagicFileMatch::MAGIC_FILENAME_ARRAY)) {
4042
return true;
4143
}
4244
}

test/phpunit/AssemblyTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,18 @@ public function testContainsDistinctFile():void {
9292

9393
self::assertTrue($sut->containsDistinctFile());
9494
}
95+
96+
public function testContainsDistinctFile_magicFilename():void {
97+
$pathList = [
98+
"/var/www/_header.html",
99+
"/var/www/_new.html",
100+
"/var/www/_footer.html",
101+
];
102+
$sut = new Assembly();
103+
foreach($pathList as $path) {
104+
$sut->add($path);
105+
}
106+
107+
self::assertTrue($sut->containsDistinctFile());
108+
}
95109
}

0 commit comments

Comments
 (0)