Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
composer.lock
docs
vendor
.phpunit.result.cache
3 changes: 3 additions & 0 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ private function createAltoRoutes()

$this->altoRouter = new AltoRouter();
$this->altoRouter->setBasePath($this->basePath);
$this->altoRouter->addMatchTypes([
'' => '[^/]++',
]);
$this->altoRoutesCreated = true;

foreach ($this->routes as $route) {
Expand Down
17 changes: 17 additions & 0 deletions tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,23 @@ public function params_are_parsed_and_passed_into_callback_function()
$this->assertSame(1, $count);
}

/** @test */
public function params_may_contain_full_stops()
{
$request = new ServerRequest([], [], '/posts/a.b.c', 'GET');
$router = new Router;

$route = $router->get('/posts/{postId}', function ($params) use (&$count) {
$count++;

$this->assertInstanceOf(RouteParams::class, $params);
$this->assertSame('a.b.c', $params->postId);
});
$router->match($request);

$this->assertSame(1, $count);
}

/** @test */
public function params_are_parsed_and_passed_into_callback_function_when_surrounded_by_whitespace()
{
Expand Down