diff --git a/src/CollectionFactory.php b/src/CollectionFactory.php index a2dc635..c9c80be 100644 --- a/src/CollectionFactory.php +++ b/src/CollectionFactory.php @@ -25,7 +25,7 @@ public function __construct(Client $mongodb, string $mongoDsn) public function create(string $collectionName, string $databaseName = null, array $options = []): Collection { if (false == $databaseName) { - $databaseName = parse_url($this->mongoDsn, PHP_URL_PATH); + $databaseName = ltrim(parse_url($this->mongoDsn, PHP_URL_PATH), '/'); } if (false == $databaseName) {