When using createConnectionPool with a DSN string, if the database password contains an unquoted ampersand you will get an Uncaught Error: Expected "port" to be an integer error from parsePort.
This is a notable issue because URL does not consider quoting & to be necessary.
Reproduction:
const {default: createConnectionPool} = await import('@databases/pg')
const dsn = new URL("postgres://localhost:5432/postgres")
dsn.username = 'red';
dsn.password = 'a&b^c'
dsn.href; // => 'postgres://red:a&b%5Ec@localhost:5432/postgres'
createConnectionPool(dsn.href);
Results in the error:
Uncaught Error: Expected "port" to be an integer
at parseInteger ({...}/node_modules/@databases/pg-connection-string/lib/Configuration.js:254:13)
at ConfigurationBuilder.set ({...}/node_modules/@databases/pg-connection-string/lib/Configuration.js:87:11)
at parsePort ({...}/node_modules/@databases/pg-connection-string/lib/parseConnectionURI.js:119:10)
at Object.parseConnectionURI [as default] ({...}/node_modules/@databases/pg-connection-string/lib/parseConnectionURI.js:26:26)
at parseConnectionString ({...}/node_modules/@databases/pg-connection-string/lib/index.js:33:40)
at createConnectionPool ({...}/node_modules/@databases/pg/lib/index.js:33:71)
When using createConnectionPool with a DSN string, if the database password contains an unquoted ampersand you will get an
Uncaught Error: Expected "port" to be an integererror fromparsePort.This is a notable issue because
URLdoes not consider quoting&to be necessary.Reproduction:
Results in the error: