diff --git a/src/UrlGenerator.php b/src/UrlGenerator.php index ef5674c..2226405 100644 --- a/src/UrlGenerator.php +++ b/src/UrlGenerator.php @@ -298,8 +298,8 @@ private function generatePath(array $arguments, array $queryParameters, array $p $path = str_replace('//', '/', $path); $queryString = ''; - if (!empty($notSubstitutedArguments) || !empty($queryParameters)) { - $queryString = http_build_query(array_merge($notSubstitutedArguments, $queryParameters)); + if (!empty($queryParameters)) { + $queryString = http_build_query($queryParameters); } return $path . (!empty($queryString) ? '?' . $queryString : ''); diff --git a/tests/UrlGeneratorTest.php b/tests/UrlGeneratorTest.php index 02c457e..a442687 100644 --- a/tests/UrlGeneratorTest.php +++ b/tests/UrlGeneratorTest.php @@ -209,19 +209,6 @@ public function testQueryParametersAddedAsQueryStringWithEmptyValues(): void $this->assertEquals('/test/post', $url); } - public function testExtraArgumentsAddedAsQueryString(): void - { - $routes = [ - Route::get('/test/{name}') - ->name('test'), - ]; - - $url = $this - ->createUrlGenerator($routes) - ->generate('test', ['name' => 'post', 'id' => 12, 'sort' => 'asc']); - $this->assertEquals('/test/post?id=12&sort=asc', $url); - } - public function testQueryParametersOverrideExtraArguments(): void { $routes = [ @@ -235,7 +222,7 @@ public function testQueryParametersOverrideExtraArguments(): void $this->assertEquals('/test/post?id=12&sort=asc', $url); } - public function testQueryParametersMergedWithExtraArguments(): void + public function testNotSubstitutedArgumentsRemove(): void { $routes = [ Route::get('/test/{name}') @@ -245,7 +232,7 @@ public function testQueryParametersMergedWithExtraArguments(): void $url = $this ->createUrlGenerator($routes) ->generate('test', ['name' => 'post', 'id' => 11], ['sort' => 'asc']); - $this->assertEquals('/test/post?id=11&sort=asc', $url); + $this->assertEquals('/test/post?sort=asc', $url); } public function testDefaultNotUsedForOptionalArgument(): void