diff --git a/Slim/Http/Uri.php b/Slim/Http/Uri.php index 27b1d0d59..6b877476a 100644 --- a/Slim/Http/Uri.php +++ b/Slim/Http/Uri.php @@ -218,6 +218,9 @@ public static function createFromEnvironment(Environment $env) // Query string $queryString = $env->get('QUERY_STRING', ''); + if ($queryString === '') { + $queryString = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_QUERY); + } // Fragment $fragment = ''; diff --git a/tests/Http/UriTest.php b/tests/Http/UriTest.php index fa105e349..eea89c660 100644 --- a/tests/Http/UriTest.php +++ b/tests/Http/UriTest.php @@ -633,4 +633,16 @@ public function testRequestURIContainsIndexDotPhp() ); $this->assertSame('/foo/index.php', $uri->getBasePath()); } + + public function testRequestURICanContainParams() + { + $uri = Uri::createFromEnvironment( + Environment::mock( + [ + 'REQUEST_URI' => '/foo?abc=123', + ] + ) + ); + $this->assertEquals('abc=123', $uri->getQuery()); + } }