Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cli/Valet/Ngrok.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class Ngrok
*
* @return string
*/
function currentTunnelUrl()
function currentTunnelUrl($domain = null)
{
return retry(20, function () {
return retry(20, function () use ($domain) {
$body = Request::get($this->tunnelsEndpoint)->send()->body;

// If there are active tunnels on the Ngrok instance we will spin through them and
// find the one responding on HTTP. Each tunnel has an HTTP and a HTTPS address
// but for local testing purposes we just desire the plain HTTP URL endpoint.
if (isset($body->tunnels) && count($body->tunnels) > 0) {
return $this->findHttpTunnelUrl($body->tunnels);
return $this->findHttpTunnelUrl($body->tunnels, $domain);
} else {
throw new DomainException("Tunnel not established.");
}
Expand All @@ -36,10 +36,10 @@ function currentTunnelUrl()
* @param array $tunnels
* @return string|null
*/
function findHttpTunnelUrl($tunnels)
function findHttpTunnelUrl($tunnels, $domain)
{
foreach ($tunnels as $tunnel) {
if ($tunnel->proto === 'http') {
if ($tunnel->proto === 'http' && strpos($tunnel->config->addr, $domain) ) {
return $tunnel->public_url;
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@
/**
* Echo the currently tunneled URL.
*/
$app->command('fetch-share-url', function () {
output(Ngrok::currentTunnelUrl());
$app->command('fetch-share-url [domain]', function ($domain = null) {
output(Ngrok::currentTunnelUrl($domain ?: Site::host(getcwd()).'.'.Configuration::read()['tld']));
})->descriptions('Get the URL to the current Ngrok tunnel');

/**
Expand Down