diff --git a/cli/Valet/Ngrok.php b/cli/Valet/Ngrok.php index 52de298..5176592 100644 --- a/cli/Valet/Ngrok.php +++ b/cli/Valet/Ngrok.php @@ -51,7 +51,7 @@ public function findHttpTunnelUrl($tunnels, $domain) // find the one responding on HTTP. Each tunnel has an HTTP and a HTTPS address // but for local dev purposes we just desire the plain HTTP URL endpoint. foreach ($tunnels as $tunnel) { - if ($tunnel->proto === 'http' && strpos($tunnel->config->addr, $domain)) { + if ($tunnel->proto === 'http' && strpos($tunnel->config->addr, strtolower($domain))) { return $tunnel->public_url; } } diff --git a/tests/NgrokTest.php b/tests/NgrokTest.php new file mode 100644 index 0000000..42aed42 --- /dev/null +++ b/tests/NgrokTest.php @@ -0,0 +1,66 @@ + 'https', + 'config' => (object) [ + 'addr' => 'http://mysite.test:80', + ], + 'public_url' => 'http://bad-proto.ngrok.io/', + ], + (object) [ + 'proto' => 'http', + 'config' => (object) [ + 'addr' => 'http://nottherightone.test:80', + ], + 'public_url' => 'http://bad-site.ngrok.io/', + ], + (object) [ + 'proto' => 'http', + 'config' => (object) [ + 'addr' => 'http://mysite.test:80', + ], + 'public_url' => 'http://right-one.ngrok.io/', + ], + ]; + + $ngrok = new Ngrok; + $this->assertEquals('http://right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'mysite')); + } + + public function test_it_checks_against_lowercased_domain() + { + $tunnels = [ + (object) [ + 'proto' => 'http', + 'config' => (object) [ + 'addr' => 'http://mysite.test:80', + ], + 'public_url' => 'http://right-one.ngrok.io/', + ], + ]; + + $ngrok = new Ngrok; + $this->assertEquals('http://right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'MySite')); + } +} diff --git a/valet b/valet index cd01a11..63bcfb3 100755 --- a/valet +++ b/valet @@ -69,6 +69,9 @@ then PORT=80 fi + # Lowercase the host to match how the rest of our domains are looked up + HOST=$(echo "$HOST" | tr '[:upper:]' '[:lower:]') + # Fetch Ngrok URL In Background... bash "$DIR/cli/scripts/fetch-share-url.sh" "$HOST" &