We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3b622a commit b1ed166Copy full SHA for b1ed166
src/Jenssegers/Mongodb/Connection.php
@@ -4,6 +4,7 @@
4
5
use Illuminate\Database\Connection as BaseConnection;
6
use Illuminate\Support\Arr;
7
+use Illuminate\Support\Str;
8
use MongoDB\Client;
9
10
class Connection extends BaseConnection
@@ -168,9 +169,15 @@ protected function hasDsnString(array $config)
168
169
*/
170
protected function getDsnString(array $config)
171
{
- $dsn = rawurlencode($config['dsn']);
172
-
173
- return "mongodb://{$dsn}";
+ $dsn_string = $config['dsn'];
+
174
+ if ( Str::contains($dsn_string, 'mongodb://') ){
175
+ $dsn_string = Str::replaceFirst('mongodb://', '', $dsn_string);
176
+ }
177
178
+ $dsn_string = rawurlencode($dsn_string);
179
180
+ return "mongodb://{$dsn_string}";
181
}
182
183
/**
0 commit comments