File tree 2 files changed +9
-1
lines changed
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) {
456
456
host,
457
457
port,
458
458
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' ,
460
460
user : o . user || o . username || auth [ 0 ] || env . PGUSERNAME || os . userInfo ( ) . username ,
461
461
pass : o . pass || o . password || auth [ 1 ] || env . PGPASSWORD || '' ,
462
462
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() => {
47
47
return [ 1 , result ]
48
48
} )
49
49
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
+
50
58
t ( 'Result is array' , async ( ) =>
51
59
[ true , Array . isArray ( await sql `select 1` ) ]
52
60
)
You can’t perform that action at this time.
0 commit comments