File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ function parse(str) {
4747
4848 var auth = ( result . auth || ':' ) . split ( ':' ) ;
4949 config . user = auth [ 0 ] ;
50- config . password = auth [ 1 ] ;
50+ config . password = auth . splice ( 1 ) . join ( ':' ) ;
5151
5252 var ssl = result . query . ssl ;
5353 if ( ssl === 'true' || ssl === '1' ) {
Original file line number Diff line number Diff line change @@ -69,6 +69,20 @@ test('password contains < and/or > characters', function(t){
6969 t . end ( ) ;
7070} ) ;
7171
72+ test ( 'password contains colons' , function ( t ) {
73+ var sourceConfig = {
74+ user :'brian' ,
75+ password : 'hello:pass:world' ,
76+ port : 5432 ,
77+ host : 'localhost' ,
78+ database : 'postgres'
79+ } ;
80+ var connectionString = 'postgres://' + sourceConfig . user + ':' + sourceConfig . password + '@' + sourceConfig . host + ':' + sourceConfig . port + '/' + sourceConfig . database ;
81+ var subject = parse ( connectionString ) ;
82+ t . equal ( subject . password , sourceConfig . password ) ;
83+ t . end ( ) ;
84+ } ) ;
85+
7286test ( 'username or password contains weird characters' , function ( t ) {
7387 var strang = 'pg://my f%irst name:is&%awesome!@localhost:9000' ;
7488 var subject = parse ( strang ) ;
You can’t perform that action at this time.
0 commit comments