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 @@ -24,6 +24,10 @@ function parse(str) {
2424 }
2525 }
2626
27+ var auth = ( result . auth || ':' ) . split ( ':' ) ;
28+ config . user = auth [ 0 ] ;
29+ config . password = auth . splice ( 1 ) . join ( ':' ) ;
30+
2731 config . port = result . port ;
2832 if ( result . protocol == 'socket:' ) {
2933 config . host = decodeURI ( result . pathname ) ;
@@ -41,10 +45,6 @@ function parse(str) {
4145 }
4246 config . database = pathname && decodeURI ( pathname ) ;
4347
44- var auth = ( result . auth || ':' ) . split ( ':' ) ;
45- config . user = auth [ 0 ] ;
46- config . password = auth . splice ( 1 ) . join ( ':' ) ;
47-
4848 if ( config . ssl === 'true' || config . ssl === '1' ) {
4949 config . ssl = true ;
5050 }
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