diff --git a/.gitignore b/.gitignore index f02a2f8..b6285d6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build composer.lock docs vendor +.phpunit.result.cache diff --git a/src/Router.php b/src/Router.php index 11d8374..fe5f055 100644 --- a/src/Router.php +++ b/src/Router.php @@ -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) { diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 16184f7..b6fbb48 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -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() {