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
2 changes: 1 addition & 1 deletion server.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if (Server::hostIsIpAddress($_SERVER['HTTP_HOST'])) {
$uriForIpAddressExtraction = ltrim($_SERVER['REQUEST_URI'], '/');

if ($host = Server::valetSiteFromIpAddressUri($uriForIpAddressExtraction, $valetConfig['tld'])) {
if ($host = Server::valetSiteFromIpAddressUri($uriForIpAddressExtraction, $valetConfig['domain'])) {
$_SERVER['HTTP_HOST'] = $host;
$_SERVER['REQUEST_URI'] = str_replace($host, '', $uriForIpAddressExtraction);
}
Expand Down
26 changes: 26 additions & 0 deletions tests/Unit/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,30 @@ public function it_does_not_treat_a_sibling_prefix_dir_as_inside(): void
@rmdir($sibling);
}
}

/**
* @test
*/
public function it_extracts_the_valet_site_from_an_ip_address_uri(): void
{
// Mirrors the LAN/IP-access flow: REQUEST_URI is "domain.test/auth/login"
// (leading slash already trimmed) and the TLD comes from config['domain'].
$this->assertSame(
'my-site.test',
Server::valetSiteFromIpAddressUri('my-site.test/auth/login', 'test')
);
$this->assertSame(
'my-site.test',
Server::valetSiteFromIpAddressUri('my-site.test', 'test')
);
}

/**
* @test
*/
public function it_returns_null_when_the_ip_address_uri_has_no_matching_tld(): void
{
$this->assertNull(Server::valetSiteFromIpAddressUri('my-site.dev/auth', 'test'));
$this->assertNull(Server::valetSiteFromIpAddressUri('', 'test'));
}
}
Loading