Update getAbsoluteUri() for query string uris
Apply same rules to query string only URIs as what's being used for URIs containing only hash/anchor values
This commit is contained in:
parent
b7ed32a36b
commit
965408fd2d
@ -522,9 +522,9 @@ abstract class Client
|
|||||||
return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri;
|
return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// anchor?
|
// anchor or query string parameters?
|
||||||
if (!$uri || '#' == $uri[0]) {
|
if (!$uri || '#' == $uri[0] || '?' == $uri[0]) {
|
||||||
return preg_replace('/#.*?$/', '', $currentUri).$uri;
|
return preg_replace('/[#?].*?$/', '', $currentUri).$uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('/' !== $uri[0]) {
|
if ('/' !== $uri[0]) {
|
||||||
|
@ -212,6 +212,15 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$client->request('GET', 'http://www.example.com/');
|
$client->request('GET', 'http://www.example.com/');
|
||||||
$client->request('GET', 'http');
|
$client->request('GET', 'http');
|
||||||
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
||||||
|
|
||||||
|
$client = new TestClient();
|
||||||
|
$client->request('GET', 'http://www.example.com/foo');
|
||||||
|
$client->request('GET', '?');
|
||||||
|
$this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
|
||||||
|
$client->request('GET', '?');
|
||||||
|
$this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
|
||||||
|
$client->request('GET', '?foo=bar');
|
||||||
|
$this->assertEquals('http://www.example.com/foo?foo=bar', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequestReferer()
|
public function testRequestReferer()
|
||||||
|
Reference in New Issue
Block a user