Preserve remainder of path in URI after database (redis scheme).

This commit is contained in:
Daniele Alessandri
2015-07-30 11:11:30 +02:00
parent 8106c8b00a
commit 2fc0e56a09
2 changed files with 26 additions and 2 deletions
+7 -2
View File
@@ -114,9 +114,14 @@ class Parameters implements ParametersInterface
unset($parsed['pass']);
}
if (isset($parsed['path']) && preg_match('/^\/(\d+)\/?/', $parsed['path'], $path)) {
if (isset($parsed['path']) && preg_match('/^\/(\d+)(\/.*)?/', $parsed['path'], $path)) {
$parsed['database'] = $path[1];
unset($parsed['path']);
if (isset($path[2])) {
$parsed['path'] = $path[2];
} else {
unset($parsed['path']);
}
}
}
@@ -178,6 +178,25 @@ class ParametersTest extends PredisTestCase
$this->assertSame($expected, $parameters);
}
/**
* @group disconnected
*/
public function testParsingURIWithRedisSchemeMustPreserveRemainderOfPath()
{
$uri = 'redis://10.10.10.10/5/rest/of/path';
$expected = array(
'scheme' => 'redis',
'host' => '10.10.10.10',
'path' => '/rest/of/path',
'database' => '5',
);
$parameters = Parameters::parse($uri);
$this->assertSame($expected, $parameters);
}
/**
* @group disconnected
*/