Skip to content

Commit a16f196

Browse files
committed
Merge branch 'adambro-request_uri_with_params' into 3.x
Closes 1896
2 parents 69ae05e + ab5fa78 commit a16f196

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Slim/Http/Uri.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ public static function createFromEnvironment(Environment $env)
218218

219219
// Query string
220220
$queryString = $env->get('QUERY_STRING', '');
221+
if ($queryString === '') {
222+
$queryString = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_QUERY);
223+
}
221224

222225
// Fragment
223226
$fragment = '';

tests/Http/UriTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,4 +632,16 @@ public function testRequestURIContainsIndexDotPhp()
632632
);
633633
$this->assertSame('/foo/index.php', $uri->getBasePath());
634634
}
635+
636+
public function testRequestURICanContainParams()
637+
{
638+
$uri = Uri::createFromEnvironment(
639+
Environment::mock(
640+
[
641+
'REQUEST_URI' => '/foo?abc=123',
642+
]
643+
)
644+
);
645+
$this->assertEquals('abc=123', $uri->getQuery());
646+
}
635647
}

0 commit comments

Comments
 (0)