Skip to content

Commit b16559a

Browse files
committed
Merge branch 'master' into feature/links-with-parked
2 parents 921776f + beda122 commit b16559a

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

cli/Valet/Site.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,21 @@ function parked()
146146
*/
147147
function getCertificates($path)
148148
{
149+
$config = $this->config->read();
150+
149151
return collect($this->files->scandir($path))->filter(function ($value, $key) {
150152
return ends_with($value, '.crt');
151-
})->map(function ($cert) {
153+
})->map(function ($cert) use ($config) {
152154
$certWithoutSuffix = substr($cert, 0, -4);
153-
return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, '.'));
155+
$trimToString = '.';
156+
157+
// If we have the cert ending in our tld strip that tld specifically
158+
// if not then just strip the last segment for backwards compatibility.
159+
if (ends_with($certWithoutSuffix, $config['tld'])) {
160+
$trimToString .= $config['tld'];
161+
}
162+
163+
return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, $trimToString));
154164
})->flip();
155165
}
156166

cli/valet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
Container::setInstance(new Container);
3333

34-
$version = '2.4.2';
34+
$version = '2.5.0';
3535

3636
$app = new Application('Laravel Valet', $version);
3737

@@ -250,7 +250,7 @@
250250
* Stop the daemon services.
251251
*/
252252
$app->command('stop', function () {
253-
PhpFpm::stop();
253+
PhpFpm::stopRunning();
254254

255255
Nginx::stop();
256256

tests/SiteTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@ public function tearDown()
2828
}
2929

3030

31+
public function test_get_certificates_will_return_with_multi_segment_tld()
32+
{
33+
$files = Mockery::mock(Filesystem::class);
34+
$files->shouldReceive('scandir')
35+
->once()
36+
->with($certPath = '/Users/testuser/.config/valet/Certificates')
37+
->andReturn(['helloworld.multi.segment.tld.com.crt']);
38+
$config = Mockery::mock(Configuration::class);
39+
$config->shouldReceive('read')
40+
->once()
41+
->andReturn(['tld' => 'multi.segment.tld.com']);
42+
43+
swap(Filesystem::class, $files);
44+
swap(Configuration::class, $config);
45+
46+
/** @var Site $site */
47+
$site = resolve(Site::class);
48+
$certs = $site->getCertificates($certPath);
49+
$this->assertSame(['helloworld' => 0], $certs->all());
50+
}
51+
52+
3153
public function test_get_sites_will_return_if_secured()
3254
{
3355
$files = Mockery::mock(Filesystem::class);
@@ -206,6 +228,12 @@ public function test_certificates_trim_tld_for_custom_tlds()
206228
'fiveletters.local.crt',
207229
]);
208230

231+
$config = Mockery::mock(Configuration::class);
232+
$config->shouldReceive('read')
233+
->once()
234+
->andReturn(['tld' => 'other']);
235+
236+
swap(Configuration::class, $config);
209237
swap(Filesystem::class, $files);
210238

211239
$site = resolve(Site::class);

0 commit comments

Comments
 (0)