diff --git a/src/Connection.php b/src/Connection.php index 590f29d82..c13077d99 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -200,7 +200,7 @@ public function setDefaultDatabaseName($name) public function getDefaultDatabaseName() { if ($this->_defaultDatabaseName === null) { - if (preg_match('/^mongodb:\\/\\/.+\\/([^?&]+)/s', $this->dsn, $matches)) { + if (preg_match('/^mongodb(:|\+srv:)\\/\\/.+\\/([^?&]+)/s', $this->dsn, $matches)) { $this->_defaultDatabaseName = $matches[1]; } else { throw new InvalidConfigException("Unable to determine default database name from dsn.");