diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index c2c498d7b..6adb2842b 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -222,7 +222,7 @@ class CakeRequest implements ArrayAccess { $uri = substr($uri, strlen($base)); } if (strpos($uri, '?') !== false) { - $uri = parse_url($uri, PHP_URL_PATH); + list($uri) = explode('?', $uri, 2); } if (empty($uri) || $uri == '/' || $uri == '//') { return '/'; diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 1ccd441b2..33bc02d82 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -104,11 +104,26 @@ class CakeRequestTest extends CakeTestCase { $_GET = array(); $request = new CakeRequest('some/path?one=something&two=else'); $expected = array('one' => 'something', 'two' => 'else'); - $this->assertEquals($request->query, $expected); + $this->assertEquals($expected, $request->query); $this->assertEquals('some/path?one=something&two=else', $request->url); } +/** + * Test that named arguments + querystrings are handled correctly. + * + * @return void + */ + public function testQueryStringAndNamedParams() { + $_SERVER['REQUEST_URI'] = '/tasks/index/page:1?ts=123456'; + $request = new CakeRequest(); + $this->assertEquals('tasks/index/page:1', $request->url); + + $_SERVER['REQUEST_URI'] = '/tasks/index/page:1/?ts=123456'; + $request = new CakeRequest(); + $this->assertEquals('tasks/index/page:1/', $request->url); + } + /** * test addParams() method * @@ -1623,6 +1638,7 @@ XML; ); } + /** * loadEnvironment method *