Skip to content

Commit 0f3ab1f

Browse files
authored
Ignore invalid paths (#1478)
1 parent a21d0bf commit 0f3ab1f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cli/Valet/Server.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ public function sitePath(string $siteName): ?string
160160
$domain = static::domainFromSiteName($siteName);
161161

162162
foreach ($this->config['paths'] as $path) {
163+
if (! is_dir($path)) {
164+
continue;
165+
}
166+
163167
$handle = opendir($path);
164168

165169
if ($handle === false) {

tests/ServerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ public function test_it_returns_null_default_site_path_if_not_set()
9090
$this->assertNull($server->defaultSitePath());
9191
}
9292

93+
public function test_it_ignores_invalid_paths()
94+
{
95+
$server = new Server(['paths' => ['fake' => __DIR__.'/invalid_path']]);
96+
97+
$this->assertNull($server->sitePath('tighten'));
98+
}
99+
93100
public function test_it_tests_whether_host_is_ip_address()
94101
{
95102
$this->assertTrue(Server::hostIsIpAddress('192.168.1.1'));

0 commit comments

Comments
 (0)