@@ -36,8 +36,11 @@ Object.assign(Postgres, {
36
36
37
37
module . exports = Postgres
38
38
39
- function Postgres ( url , options ) {
40
- options = parseOptions ( url , options )
39
+ function Postgres ( a , b ) {
40
+ if ( arguments . length && ! a )
41
+ throw new Error ( a + ' - is not a url or connection object' )
42
+
43
+ const options = parseOptions ( a , b )
41
44
42
45
const max = Math . max ( 1 , options . max )
43
46
, connections = Queue ( )
@@ -444,10 +447,10 @@ function Postgres(url, options) {
444
447
}
445
448
}
446
449
447
- function parseOptions ( uri , options ) {
450
+ function parseOptions ( a , b ) {
448
451
const env = process . env // eslint-disable-line
449
- , url = typeof uri === 'string' ? Url . parse ( uri , true ) : { query : { } , pathname : '' }
450
- , o = ( typeof uri === 'string' ? options : uri ) || { }
452
+ , url = typeof a === 'string' ? Url . parse ( a , true ) : { query : { } , pathname : '' }
453
+ , o = ( typeof a === 'string' ? b : a ) || { }
451
454
, auth = ( url . auth || '' ) . split ( ':' )
452
455
, host = o . hostname || o . host || url . hostname || env . PGHOST || 'localhost'
453
456
, port = o . port || url . port || env . PGPORT || 5432
0 commit comments