File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
packages/client/lib/client Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,14 @@ describe('Client', () => {
167
167
}
168
168
) ;
169
169
} ) ;
170
+
171
+ it ( 'DB in URL should be parsed' , async ( ) => {
172
+ const client = RedisClient . create ( {
173
+ url : 'redis://user:secret@localhost:6379/5'
174
+ } ) ;
175
+
176
+ assert . equal ( client ?. options ?. database , 5 ) ;
177
+ } )
170
178
} ) ;
171
179
172
180
describe ( 'parseOptions' , ( ) => {
Original file line number Diff line number Diff line change @@ -496,8 +496,14 @@ export default class RedisClient<
496
496
this . _commandOptions = options . commandOptions ;
497
497
}
498
498
499
- if ( options ) {
500
- return RedisClient . parseOptions ( options ) ;
499
+ if ( options ?. url ) {
500
+ const parsedOptions = RedisClient . parseOptions ( options ) ;
501
+
502
+ if ( parsedOptions ?. database ) {
503
+ this . _self . #selectedDB = parsedOptions . database ;
504
+ }
505
+
506
+ return parsedOptions ;
501
507
}
502
508
503
509
return options ;
You can’t perform that action at this time.
0 commit comments