Skip to content

Commit e6060ba

Browse files
committed
Fix url auth
1 parent 418383a commit e6060ba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ function parseOptions(uri, options) {
402402
const o = options || uri
403403
, env = process.env // eslint-disable-line
404404
, url = options ? Url.parse(uri, true) : { query: {}, pathname: '' }
405+
, auth = (url.auth || '').split(':')
405406
, host = o.hostname || o.host || url.hostname || env.PGHOST || 'localhost'
406407
, port = o.port || url.port || env.PGPORT || 5432
407408

@@ -410,8 +411,8 @@ function parseOptions(uri, options) {
410411
port,
411412
path : o.path || host.indexOf('/') > -1 && host + '/.s.PGSQL.' + port,
412413
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 || '',
415416
max : o.max || url.query.max || Math.max(1, os.cpus().length),
416417
fifo : o.fifo || url.query.fifo || false,
417418
transform : o.transform || (x => x),

0 commit comments

Comments
 (0)