Commit 99342a75 authored by Derek Price's avatar Derek Price

Fix getDefaultDatabaseName to handle +srv URLs.

Fixes #1977, fixes #1861
parent 1574aff9
...@@ -128,7 +128,7 @@ class Connection extends BaseConnection ...@@ -128,7 +128,7 @@ class Connection extends BaseConnection
protected function getDefaultDatabaseName($dsn, $config) protected function getDefaultDatabaseName($dsn, $config)
{ {
if (empty($config['database'])) { if (empty($config['database'])) {
if (preg_match('/^mongodb:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) { if (preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
$config['database'] = $matches[1]; $config['database'] = $matches[1];
} else { } else {
throw new InvalidArgumentException("Database is not properly configured."); throw new InvalidArgumentException("Database is not properly configured.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment