Unverified Commit 01dfe3c0 authored by Divine's avatar Divine Committed by GitHub

Merge pull request #1976 from PartechGSS/partech-bugfixes

Fix getDefaultDatabaseName to handle +srv URLs.
parents 1574aff9 99342a75
...@@ -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