1
0
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:
Dave Marshall 2012-07-24 16:34:59 +01:00
parent bc6cbc8cd3
commit f0ecc3ab65
2 changed files with 13 additions and 3 deletions

View File

@ -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, '');
}
}
}

View File

@ -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
*/