1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00

Merge branch 'feature/support-parked-domains' of https://github.com/antonioribeiro/valet into antonioribeiro-feature/support-parked-domains

This commit is contained in:
Matt Stauffer
2022-04-13 23:05:38 -04:00
2 changed files with 23 additions and 5 deletions

View File

@@ -1073,6 +1073,24 @@ public function certificatesPath($url = null, $extension = null)
return $this->valetHomePath().'/Certificates'.$url.$extension; return $this->valetHomePath().'/Certificates'.$url.$extension;
} }
/**
* Make the domain name based on parked domains or the internal TLD.
*
* @return string
*/
public function domain($domain)
{
if ($this->parked()->pluck('site')->contains($domain)) {
return $domain;
}
if ($parked = $this->parked()->where('path', getcwd())->first()) {
return $parked['site'];
}
return ($domain ?: $this->host(getcwd())).'.'.$this->config->read()['tld'];
}
/** /**
* Replace Loopback configuration line in Valet site configuration file contents. * Replace Loopback configuration line in Valet site configuration file contents.
* *

View File

@@ -180,7 +180,7 @@
* Secure the given domain with a trusted TLS certificate. * Secure the given domain with a trusted TLS certificate.
*/ */
$app->command('secure [domain] [--expireIn=]', function ($domain = null, $expireIn = 368) { $app->command('secure [domain] [--expireIn=]', function ($domain = null, $expireIn = 368) {
$url = ($domain ?: Site::host(getcwd())).'.'.Configuration::read()['tld']; $url = Site::domain($domain);
Site::secure($url, null, $expireIn); Site::secure($url, null, $expireIn);
@@ -201,7 +201,7 @@
return; return;
} }
$url = ($domain ?: Site::host(getcwd())).'.'.Configuration::read()['tld']; $url = Site::domain($domain);
Site::unsecure($url); Site::unsecure($url);
@@ -280,8 +280,8 @@
* Open the current or given directory in the browser. * Open the current or given directory in the browser.
*/ */
$app->command('open [domain]', function ($domain = null) { $app->command('open [domain]', function ($domain = null) {
$url = 'http://'.($domain ?: Site::host(getcwd())).'.'.Configuration::read()['tld']; $url = "http://".Site::domain($domain);
CommandLine::runAsUser('open '.escapeshellarg($url)); CommandLine::runAsUser("open ".escapeshellarg($url));
})->descriptions('Open the site for the current (or specified) directory in your browser'); })->descriptions('Open the site for the current (or specified) directory in your browser');
/** /**
@@ -295,7 +295,7 @@
* Echo the currently tunneled URL. * Echo the currently tunneled URL.
*/ */
$app->command('fetch-share-url [domain]', function ($domain = null) { $app->command('fetch-share-url [domain]', function ($domain = null) {
output(Ngrok::currentTunnelUrl($domain ?: Site::host(getcwd()).'.'.Configuration::read()['tld'])); output(Ngrok::currentTunnelUrl(Site::domain($domain)));
})->descriptions('Get the URL to the current Ngrok tunnel'); })->descriptions('Get the URL to the current Ngrok tunnel');
/** /**