Skip to content

Commit f3b395b

Browse files
authored
Merge pull request #505 from laravel/fix-valet-links-non-dev
Fix valet links non dev
2 parents ecfcaf4 + a777769 commit f3b395b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

cli/Valet/Site.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function link($target, $link)
6464
*
6565
* @return \Illuminate\Support\Collection
6666
*/
67-
function links() {
67+
function links()
68+
{
6869
$certsPath = VALET_HOME_PATH.'/Certificates';
6970

7071
$this->files->ensureDirExists($certsPath, user());
@@ -82,7 +83,7 @@ function links() {
8283
*/
8384
function getCertificates($path)
8485
{
85-
return collect($this->files->scanDir($path))->filter(function ($value, $key) {
86+
return collect($this->files->scandir($path))->filter(function ($value, $key) {
8687
return ends_with($value, '.crt');
8788
})->map(function ($cert) {
8889
return substr($cert, 0, strripos($cert, '.', -5));
@@ -100,7 +101,7 @@ function getLinks($path, $certs)
100101
{
101102
$config = $this->config->read();
102103

103-
return collect($this->files->scanDir($path))->mapWithKeys(function ($site) use ($path) {
104+
return collect($this->files->scandir($path))->mapWithKeys(function ($site) use ($path) {
104105
return [$site => $this->files->readLink($path.'/'.$site)];
105106
})->map(function ($path, $site) use ($certs, $config) {
106107
$secured = $certs->has($site);

tests/SiteTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ public function test_prune_links_removes_broken_symlinks_in_sites_path()
6464
$site->pruneLinks();
6565
$this->assertFileNotExists(__DIR__.'/output/link');
6666
}
67+
68+
69+
public function test_certificates_trim_tld_for_custom_tlds()
70+
{
71+
$files = Mockery::mock(Filesystem::class);
72+
$files->shouldReceive('scandir')->once()->andReturn([
73+
'threeletters.dev.crt',
74+
'fiveletters.local.crt',
75+
]);
76+
77+
swap(Filesystem::class, $files);
78+
79+
$site = resolve(Site::class);
80+
$certs = $site->getCertificates('fake-cert-path')->flip();
81+
82+
$this->assertEquals('threeletters', $certs->first());
83+
$this->assertEquals('fiveletters', $certs->last());
84+
}
6785
}
6886

6987

0 commit comments

Comments
 (0)