From 6c6e71f5dd0c1e7681a48657a523ba5676b7ba4f Mon Sep 17 00:00:00 2001 From: Metola Date: Sun, 10 Jan 2021 22:27:58 +0100 Subject: [PATCH 1/2] 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."); From 0f40503cb4b04716801a50f971043037f73fa7af Mon Sep 17 00:00:00 2001 From: Metola Date: Mon, 11 Jan 2021 09:41:56 +0100 Subject: [PATCH 2/2] Update Connection.php for add +srv 2 Change position in array --- src/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Connection.php b/src/Connection.php index c13077d99..e13671afb 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -201,7 +201,7 @@ public function getDefaultDatabaseName() { if ($this->_defaultDatabaseName === null) { if (preg_match('/^mongodb(:|\+srv:)\\/\\/.+\\/([^?&]+)/s', $this->dsn, $matches)) { - $this->_defaultDatabaseName = $matches[1]; + $this->_defaultDatabaseName = $matches[2]; } else { throw new InvalidConfigException("Unable to determine default database name from dsn."); }