mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
Merge pull request #1253 from laravel/mes/lowercase-matching-ngrok
Update Ngrok (valet share) to lowercase domains before matching
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
66
tests/NgrokTest.php
Normal file
66
tests/NgrokTest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Valet\Ngrok;
|
||||
use function Valet\user;
|
||||
|
||||
class NgrokTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase
|
||||
{
|
||||
public function set_up()
|
||||
{
|
||||
$_SERVER['SUDO_USER'] = user();
|
||||
|
||||
Container::setInstance(new Container);
|
||||
}
|
||||
|
||||
public function tear_down()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function test_it_matches_correct_share_tunnel()
|
||||
{
|
||||
$tunnels = [
|
||||
(object) [
|
||||
'proto' => '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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user