From 6c6e71f5dd0c1e7681a48657a523ba5676b7ba4f Mon Sep 17 00:00:00 2001 From: Metola Date: Sun, 10 Jan 2021 22:27:58 +0100 Subject: [PATCH] Update Connection.php for add +srv Fix issue #304 --- src/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.");