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', () => {
167167 }
168168 ) ;
169169 } ) ;
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+ } )
170178 } ) ;
171179
172180 describe ( 'parseOptions' , ( ) => {
Original file line number Diff line number Diff line change @@ -496,8 +496,14 @@ export default class RedisClient<
496496 this . _commandOptions = options . commandOptions ;
497497 }
498498
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 ;
501507 }
502508
503509 return options ;
You can’t perform that action at this time.
0 commit comments