File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ function parse(str) {
2323 }
2424 }
2525
26+ var auth = ( result . auth || ':' ) . split ( ':' ) ;
27+ config . user = auth [ 0 ] ;
28+ config . password = auth . splice ( 1 ) . join ( ':' ) ;
29+
2630 config . port = result . port ;
2731 if ( result . protocol == 'socket:' ) {
2832 config . host = decodeURI ( result . pathname ) ;
@@ -40,10 +44,6 @@ function parse(str) {
4044 }
4145 config . database = pathname && decodeURI ( pathname ) ;
4246
43- var auth = ( result . auth || ':' ) . split ( ':' ) ;
44- config . user = auth [ 0 ] ;
45- config . password = auth . splice ( 1 ) . join ( ':' ) ;
46-
4747 if ( config . ssl === 'true' || config . ssl === '1' ) {
4848 config . ssl = true ;
4949 }
Original file line number Diff line number Diff line change @@ -52,6 +52,14 @@ describe('parse', function(){
5252 subject . client_encoding . should . equal ( 'utf8' ) ;
5353 } ) ;
5454
55+ it ( 'initializing with unix domain socket, username and password' , function ( ) {
56+ var subject = parse ( 'socket://brian:pw@/var/run/?db=mydb' ) ;
57+ subject . user . should . equal ( 'brian' ) ;
58+ subject . password . should . equal ( 'pw' ) ;
59+ subject . host . should . equal ( '/var/run/' ) ;
60+ subject . database . should . equal ( 'mydb' ) ;
61+ } ) ;
62+
5563 it ( 'password contains < and/or > characters' , function ( ) {
5664 var sourceConfig = {
5765 user :'brian' ,
You can’t perform that action at this time.
0 commit comments