Skip to content

Commit

Permalink
Merge pull request #1976 from PartechGSS/partech-bugfixes
Browse files Browse the repository at this point in the history
Fix getDefaultDatabaseName to handle +srv URLs.
  • Loading branch information
divine committed Mar 3, 2020
2 parents 1574aff + 99342a7 commit 01dfe3c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Connection.php
Expand Up @@ -128,7 +128,7 @@ public function getDatabaseName()
protected function getDefaultDatabaseName($dsn, $config)
{
if (empty($config['database'])) {
if (preg_match('/^mongodb:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
if (preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
$config['database'] = $matches[1];
} else {
throw new InvalidArgumentException("Database is not properly configured.");
Expand Down

0 comments on commit 01dfe3c

Please sign in to comment.