Skip to content

Commit

Permalink
fix(http-routing): allow hosts without "." in url generation context
Browse files Browse the repository at this point in the history
Fix: #161
  • Loading branch information
calvinalkan committed Dec 6, 2022
1 parent febf531 commit c8ee18e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function __construct(
bool $https_by_default = true
) {
Assert::stringNotEmpty($host, '$host cant be empty.');
Assert::contains($host, '.', 'Expected $host to contain a [.].');
Assert::notContains($host, 'http', '$host must not contain a scheme.');
Assert::notContains($host, '://', '$host must not contain a scheme.');
$this->host = $host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,30 @@ public function test_properties(): void
$this->assertSame(4000, $context->httpsPort());
$this->assertFalse($context->httpsByDefault());
}


/**
* @test
*
* @see https://github.com/snicco/snicco/issues/161
*/
public function test_host_does_not_need_a_dot(): void
{
$context = new UrlGenerationContext('nginx');

$this->assertSame('nginx', $context->host());
$this->assertSame(80, $context->httpPort());
$this->assertSame(443, $context->httpsPort());
$this->assertTrue($context->httpsByDefault());

$context = new UrlGenerationContext('nginx', 4000, 8080, false);

$this->assertSame('nginx', $context->host());
$this->assertSame(8080, $context->httpPort());
$this->assertSame(4000, $context->httpsPort());
$this->assertFalse($context->httpsByDefault());
}


/**
* @test
*/
Expand Down

0 comments on commit c8ee18e

Please sign in to comment.