mirror of
https://github.com/predis/predis.git
synced 2026-08-30 04:02:22 +00:00
Preserve remainder of path in URI after database (redis scheme).
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user