File tree 2 files changed +12
-4
lines changed 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ function parse(str) {
23
23
}
24
24
}
25
25
26
+ var auth = ( result . auth || ':' ) . split ( ':' ) ;
27
+ config . user = auth [ 0 ] ;
28
+ config . password = auth . splice ( 1 ) . join ( ':' ) ;
29
+
26
30
config . port = result . port ;
27
31
if ( result . protocol == 'socket:' ) {
28
32
config . host = decodeURI ( result . pathname ) ;
@@ -40,10 +44,6 @@ function parse(str) {
40
44
}
41
45
config . database = pathname && decodeURI ( pathname ) ;
42
46
43
- var auth = ( result . auth || ':' ) . split ( ':' ) ;
44
- config . user = auth [ 0 ] ;
45
- config . password = auth . splice ( 1 ) . join ( ':' ) ;
46
-
47
47
if ( config . ssl === 'true' || config . ssl === '1' ) {
48
48
config . ssl = true ;
49
49
}
Original file line number Diff line number Diff line change @@ -52,6 +52,14 @@ describe('parse', function(){
52
52
subject . client_encoding . should . equal ( 'utf8' ) ;
53
53
} ) ;
54
54
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
+
55
63
it ( 'password contains < and/or > characters' , function ( ) {
56
64
var sourceConfig = {
57
65
user :'brian' ,
You can’t perform that action at this time.
0 commit comments