mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 02:22:57 +01:00
Allows for 0 integers to be added as URL paths
This commit is contained in:
parent
cf95dff4da
commit
17b483600d
@ -314,13 +314,13 @@ class Url
|
||||
/**
|
||||
* Add a relative path to the currently set path
|
||||
*
|
||||
* @param string $relativePath Relative path to add
|
||||
* @param string|int $relativePath Relative path to add
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
public function addPath($relativePath)
|
||||
{
|
||||
if (!$relativePath || $relativePath == '/') {
|
||||
if ((!is_string($relativePath) && !is_int($relativePath)) || strlen($relativePath) === 0 || $relativePath === '/') {
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -127,11 +127,17 @@ class UrlTest extends \Guzzle\Tests\GuzzleTestCase
|
||||
{
|
||||
// Does nothing here
|
||||
$this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(false));
|
||||
$this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(null));
|
||||
$this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(array()));
|
||||
$this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(new \stdClass()));
|
||||
$this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(''));
|
||||
$this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath('/'));
|
||||
|
||||
$this->assertEquals('http://e.com/base/relative?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath('relative'));
|
||||
$this->assertEquals('http://e.com/base/relative?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath('/relative'));
|
||||
|
||||
$this->assertEquals('http://e.com/base/0', (string) Url::factory('http://e.com/base')->addPath(0));
|
||||
$this->assertEquals('http://e.com/base/0/1', (string) Url::factory('http://e.com/base')->addPath('0')->addPath('1'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user