Skip to content

Commit 59fe4fb

Browse files
authored
fix: query param name collision in uri function (#679)
1 parent cea122e commit 59fe4fb

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"tempest/view": "self.version"
7676
},
7777
"minimum-stability": "dev",
78+
"prefer-stable": true,
7879
"autoload": {
7980
"psr-4": {
8081
"Tempest\\Auth\\": "src/Tempest/Auth/src/",

src/Tempest/Http/src/GenericRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function toUri(array|string $action, ...$params): string
129129

130130

131131
foreach ($params as $key => $value) {
132-
if (! str_contains($uri, "{$key}")) {
132+
if (! str_contains($uri, sprintf('{%s', $key))) {
133133
$queryParams[$key] = $value;
134134

135135
continue;

tests/Integration/Http/Static/StaticGenerateCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
final class StaticGenerateCommandTest extends FrameworkIntegrationTestCase
1515
{
16-
public function test_generate(): void
16+
public function test_static_site_generate_command(): void
1717
{
1818
$appConfig = new AppConfig(baseUri: 'https://test.com');
1919
$this->container->config($appConfig);

tests/Integration/Route/RouterTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ public function test_generate_uri(): void
8888
$this->assertEquals('https://test.com/test/1/a/b/c/d', $router->toUri([TestController::class, 'withCustomRegexParams'], id: 1, name: 'a/b/c/d'));
8989
}
9090

91+
public function test_uri_generation_with_query_param(): void
92+
{
93+
$router = $this->container->get(GenericRouter::class);
94+
95+
$uri = $router->toUri(TestController::class, test: 'foo');
96+
97+
$this->assertSame('/test?test=foo', $uri);
98+
}
99+
91100
public function test_with_view(): void
92101
{
93102
$router = $this->container->get(GenericRouter::class);

0 commit comments

Comments
 (0)