Skip to content

Commit

Permalink
Merge pull request #100 from vitaly-t/patch-1
Browse files Browse the repository at this point in the history
Update connection.js
  • Loading branch information
Paxa authored Sep 26, 2020
2 parents 72e484d + 9598e2c commit a03cbec
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,19 @@ class Connection {

// Use ConnectionString lib to support parsing unix socket in connection string
static parseConnectionString(postgresUrl /*: string */) /*: ConnectionOptions */ {
var cs = new ConnectionString(postgresUrl);
if (!cs.params) cs.params = {};
if (!cs.params.application_name) cs.params.application_name = 'Postbird.app';

var cs = new ConnectionString(postgresUrl, {
params: {
application_name: 'Postbird.app'
}
});
var res = Object.assign({}, cs.params, {
host: cs.hostname,
port: cs.port || cs.params && cs.params && cs.params.socketPort || '5432',
port: cs.port || cs.params.socketPort || 5432,
database: cs.path && cs.path[0],
user: cs.user,
password: cs.password,
});
if (cs.params && 'ssl' in cs.params) {
if ('ssl' in cs.params) {
res.ssl = Boolean(cs.params.ssl)
}
delete res.socketPort;
Expand Down

0 comments on commit a03cbec

Please sign in to comment.