Skip to content

Commit

Permalink
Ignore invalid paths (#1478)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedash95 committed May 7, 2024
1 parent a21d0bf commit 0f3ab1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/Valet/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ public function sitePath(string $siteName): ?string
$domain = static::domainFromSiteName($siteName);

foreach ($this->config['paths'] as $path) {
if (! is_dir($path)) {
continue;
}

$handle = opendir($path);

if ($handle === false) {
Expand Down
7 changes: 7 additions & 0 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ public function test_it_returns_null_default_site_path_if_not_set()
$this->assertNull($server->defaultSitePath());
}

public function test_it_ignores_invalid_paths()
{
$server = new Server(['paths' => ['fake' => __DIR__.'/invalid_path']]);

$this->assertNull($server->sitePath('tighten'));
}

public function test_it_tests_whether_host_is_ip_address()
{
$this->assertTrue(Server::hostIsIpAddress('192.168.1.1'));
Expand Down

0 comments on commit 0f3ab1f

Please sign in to comment.