Skip to content

Commit 4b2f800

Browse files
committed
fix
1 parent 4f5df74 commit 4b2f800

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Dsn.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ public static function parse(string $dsn): array
250250
list($hostsPorts) = explode('#', $dsnWithoutUserPassword, 2);
251251
list($hostsPorts) = explode('?', $hostsPorts, 2);
252252
list($hostsPorts) = explode('/', $hostsPorts, 2);
253-
} else {
253+
}
254+
255+
if (empty($hostsPorts)) {
254256
return [
255257
new self(
256258
$scheme,

Tests/DsnTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ public function testShouldParseQueryParameterAsFloat(string $parameter, float $e
180180
$this->assertSame($expected, $dsn->getFloat('aName'));
181181
}
182182

183+
public function testShouldParseDSNWithoutAuthorityPart()
184+
{
185+
$dsn = Dsn::parseFirst('foo:///foo');
186+
187+
$this->assertNull($dsn->getUser());
188+
$this->assertNull($dsn->getPassword());
189+
$this->assertNull($dsn->getHost());
190+
$this->assertNull($dsn->getPort());
191+
}
192+
183193
public function testShouldReturnDefaultFloatIfNotSet()
184194
{
185195
$dsn = Dsn::parseFirst('foo:');

0 commit comments

Comments
 (0)