diff --git a/src/Route.php b/src/Route.php index e17b564..70f46da 100644 --- a/src/Route.php +++ b/src/Route.php @@ -113,7 +113,7 @@ public function getPath(?array $replacements = null): string $toReplace = []; foreach ($replacements as $wildcard => $actual) { - $toReplace['/{' . preg_quote($wildcard, '/') . '(:.*)?}/'] = $actual; + $toReplace['/{' . preg_quote($wildcard, '/') . '(:.*)?}/U'] = $actual; } $segments = []; diff --git a/tests/RouteTest.php b/tests/RouteTest.php index b4ad983..da125ff 100644 --- a/tests/RouteTest.php +++ b/tests/RouteTest.php @@ -143,15 +143,16 @@ public function process( public function testGetPathReplacesWildcards(): void { - $route = new Route('GET', '/a/{wildcard}/and/{wildcardWithMatcher:uuid}', static function () { + $route = new Route('GET', '/a/{wildcard}/and/{wildcardWithMatcher:uuid}/and/{wildcardWithMatcherAgain:uuid}', static function () { }); $path = $route->getPath([ - 'wildcard' => 'replaced-wildcard', - 'wildcardWithMatcher' => 'replaced-wildcard-with-matcher', + 'wildcard' => 'replaced-wildcard', + 'wildcardWithMatcher' => 'replaced-wildcard-with-matcher', + 'wildcardWithMatcherAgain' => 'replaced-wildcard-with-matcher-again', ]); - $this->assertSame('/a/replaced-wildcard/and/replaced-wildcard-with-matcher', $path); + $this->assertSame('/a/replaced-wildcard/and/replaced-wildcard-with-matcher/and/replaced-wildcard-with-matcher-again', $path); } public function testGetPathReplacesOptional(): void