mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 02:22:57 +01:00
Fixes #108 - Check array key exists rather than for empty
This commit is contained in:
parent
bc6cbc8cd3
commit
f0ecc3ab65
@ -63,10 +63,10 @@ class QueryString extends Collection
|
||||
$key = substr($key, 0, -2);
|
||||
}
|
||||
|
||||
if (empty($parts[1])) {
|
||||
$q->add($key, '');
|
||||
} else {
|
||||
if (array_key_exists(1, $parts)) {
|
||||
$q->add($key, rawurldecode(str_replace('+', '%20', $parts[1])));
|
||||
} else {
|
||||
$q->add($key, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +256,16 @@ class QueryStringTest extends \Guzzle\Tests\GuzzleTestCase
|
||||
$this->assertEquals('foo bar', $query->get('var'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Guzzle\Http\QueryString::fromString
|
||||
* @see https://github.com/guzzle/guzzle/issues/108
|
||||
*/
|
||||
public function testFromStringDoesntMangleZeroes()
|
||||
{
|
||||
$query = QueryString::fromString('var=0');
|
||||
$this->assertSame('0', $query->get('var'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Guzzle\Http\QueryString::__toString
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user