Skip to content

Commit 79b1c56

Browse files
authored
non-greedy regex for database name extraction
1 parent 2815f1b commit 79b1c56

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected function withFreshQueryLog($callback)
214214
protected function getDefaultDatabaseName(string $dsn, array $config): string
215215
{
216216
if (empty($config['database'])) {
217-
if (! preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
217+
if (! preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+?\\/([^?&]+)/s', $dsn, $matches)) {
218218
throw new InvalidArgumentException('Database is not properly configured.');
219219
}
220220

0 commit comments

Comments
 (0)