Skip to content

Commit

Permalink
Update Connection.php for add +srv
Browse files Browse the repository at this point in the history
Fix issue yiisoft#304
  • Loading branch information
metola authored Jan 10, 2021
1 parent 24422d4 commit 6c6e71f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 6c6e71f

Please sign in to comment.