@@ -402,6 +402,7 @@ function parseOptions(uri, options) {
402
402
const o = options || uri
403
403
, env = process . env // eslint-disable-line
404
404
, url = options ? Url . parse ( uri , true ) : { query : { } , pathname : '' }
405
+ , auth = ( url . auth || '' ) . split ( ':' )
405
406
, host = o . hostname || o . host || url . hostname || env . PGHOST || 'localhost'
406
407
, port = o . port || url . port || env . PGPORT || 5432
407
408
@@ -410,8 +411,8 @@ function parseOptions(uri, options) {
410
411
port,
411
412
path : o . path || host . indexOf ( '/' ) > - 1 && host + '/.s.PGSQL.' + port ,
412
413
database : o . database || o . db || url . pathname . slice ( 1 ) || env . PGDATABASE || 'postgres' ,
413
- user : o . user || o . username || url . user || env . PGUSERNAME || os . userInfo ( ) . username ,
414
- pass : o . pass || o . password || url . pass || env . PGPASSWORD || '' ,
414
+ user : o . user || o . username || auth [ 0 ] || env . PGUSERNAME || os . userInfo ( ) . username ,
415
+ pass : o . pass || o . password || auth [ 1 ] || env . PGPASSWORD || '' ,
415
416
max : o . max || url . query . max || Math . max ( 1 , os . cpus ( ) . length ) ,
416
417
fifo : o . fifo || url . query . fifo || false ,
417
418
transform : o . transform || ( x => x ) ,
0 commit comments