File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -456,7 +456,7 @@ function parseOptions(uri, options) {
456456 host,
457457 port,
458458 path : o . path || host . indexOf ( '/' ) > - 1 && host + '/.s.PGSQL.' + port ,
459- database : o . database || o . db || url . pathname . slice ( 1 ) || env . PGDATABASE || 'postgres' ,
459+ database : o . database || o . db || ( url . pathname || '' ) . slice ( 1 ) || env . PGDATABASE || 'postgres' ,
460460 user : o . user || o . username || auth [ 0 ] || env . PGUSERNAME || os . userInfo ( ) . username ,
461461 pass : o . pass || o . password || auth [ 1 ] || env . PGPASSWORD || '' ,
462462 max : o . max || url . query . max || Math . max ( 1 , os . cpus ( ) . length ) ,
Original file line number Diff line number Diff line change @@ -47,6 +47,14 @@ t('Connects with no options', async() => {
4747 return [ 1 , result ]
4848} )
4949
50+ t ( 'Uses default database without slash' , async ( ) =>
51+ [ 'postgres' , postgres ( 'postgres://localhost' ) . options . database ]
52+ )
53+
54+ t ( 'Uses default database with slash' , async ( ) =>
55+ [ 'postgres' , postgres ( 'postgres://localhost/' ) . options . database ]
56+ )
57+
5058t ( 'Result is array' , async ( ) =>
5159 [ true , Array . isArray ( await sql `select 1` ) ]
5260)
You can’t perform that action at this time.
0 commit comments