Skip to content

Commit 3a831fc

Browse files
committed
Run lint --fix
1 parent 4aff01e commit 3a831fc

File tree

4 files changed

+629
-290
lines changed

4 files changed

+629
-290
lines changed
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export function parse(connectionString: string): ConnectionOptions;
1+
export function parse(connectionString: string): ConnectionOptions
22

33
export interface ConnectionOptions {
4-
host: string | null;
5-
password?: string;
6-
user?: string;
7-
port?: string | null;
8-
database: string | null | undefined;
9-
client_encoding?: string;
10-
ssl?: boolean | string;
4+
host: string | null
5+
password?: string
6+
user?: string
7+
port?: string | null
8+
database: string | null | undefined
9+
client_encoding?: string
10+
ssl?: boolean | string
1111

12-
application_name?: string;
13-
fallback_application_name?: string;
12+
application_name?: string
13+
fallback_application_name?: string
1414
}
+37-35
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
'use strict'
22

3-
var url = require('url');
4-
var fs = require('fs');
3+
var url = require('url')
4+
var fs = require('fs')
55

66
//Parse method copied from https://github.com/brianc/node-postgres
77
//Copyright (c) 2010-2014 Brian Carlson (brian.m.carlson@gmail.com)
@@ -10,78 +10,80 @@ var fs = require('fs');
1010
//parses a connection string
1111
function parse(str) {
1212
//unix socket
13-
if(str.charAt(0) === '/') {
14-
var config = str.split(' ');
15-
return { host: config[0], database: config[1] };
13+
if (str.charAt(0) === '/') {
14+
var config = str.split(' ')
15+
return { host: config[0], database: config[1] }
1616
}
1717

1818
// url parse expects spaces encoded as %20
19-
var result = url.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str) ? encodeURI(str).replace(/\%25(\d\d)/g, "%$1") : str, true);
20-
var config = result.query;
19+
var result = url.parse(
20+
/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str) ? encodeURI(str).replace(/\%25(\d\d)/g, '%$1') : str,
21+
true
22+
)
23+
var config = result.query
2124
for (var k in config) {
2225
if (Array.isArray(config[k])) {
23-
config[k] = config[k][config[k].length-1];
26+
config[k] = config[k][config[k].length - 1]
2427
}
2528
}
2629

27-
var auth = (result.auth || ':').split(':');
28-
config.user = auth[0];
29-
config.password = auth.splice(1).join(':');
30+
var auth = (result.auth || ':').split(':')
31+
config.user = auth[0]
32+
config.password = auth.splice(1).join(':')
3033

31-
config.port = result.port;
32-
if(result.protocol == 'socket:') {
33-
config.host = decodeURI(result.pathname);
34-
config.database = result.query.db;
35-
config.client_encoding = result.query.encoding;
36-
return config;
34+
config.port = result.port
35+
if (result.protocol == 'socket:') {
36+
config.host = decodeURI(result.pathname)
37+
config.database = result.query.db
38+
config.client_encoding = result.query.encoding
39+
return config
3740
}
3841
if (!config.host) {
3942
// Only set the host if there is no equivalent query param.
40-
config.host = result.hostname;
43+
config.host = result.hostname
4144
}
4245

4346
// If the host is missing it might be a URL-encoded path to a socket.
44-
var pathname = result.pathname;
47+
var pathname = result.pathname
4548
if (!config.host && pathname && /^%2f/i.test(pathname)) {
46-
var pathnameSplit = pathname.split('/');
47-
config.host = decodeURIComponent(pathnameSplit[0]);
48-
pathname = pathnameSplit.splice(1).join('/');
49+
var pathnameSplit = pathname.split('/')
50+
config.host = decodeURIComponent(pathnameSplit[0])
51+
pathname = pathnameSplit.splice(1).join('/')
4952
}
5053
// result.pathname is not always guaranteed to have a '/' prefix (e.g. relative urls)
5154
// only strip the slash if it is present.
5255
if (pathname && pathname.charAt(0) === '/') {
53-
pathname = pathname.slice(1) || null;
56+
pathname = pathname.slice(1) || null
5457
}
55-
config.database = pathname && decodeURI(pathname);
58+
config.database = pathname && decodeURI(pathname)
5659

5760
if (config.ssl === 'true' || config.ssl === '1') {
58-
config.ssl = true;
61+
config.ssl = true
5962
}
6063

6164
if (config.ssl === '0') {
62-
config.ssl = false;
65+
config.ssl = false
6366
}
6467

6568
if (config.sslcert || config.sslkey || config.sslrootcert) {
66-
config.ssl = {};
69+
config.ssl = {}
6770
}
6871

6972
if (config.sslcert) {
70-
config.ssl.cert = fs.readFileSync(config.sslcert).toString();
73+
config.ssl.cert = fs.readFileSync(config.sslcert).toString()
7174
}
7275

7376
if (config.sslkey) {
74-
config.ssl.key = fs.readFileSync(config.sslkey).toString();
77+
config.ssl.key = fs.readFileSync(config.sslkey).toString()
7578
}
7679

7780
if (config.sslrootcert) {
78-
config.ssl.ca = fs.readFileSync(config.sslrootcert).toString();
81+
config.ssl.ca = fs.readFileSync(config.sslrootcert).toString()
7982
}
8083

81-
return config;
84+
return config
8285
}
8386

87+
module.exports = parse
8488

85-
module.exports = parse;
86-
87-
parse.parse = parse;
89+
parse.parse = parse

0 commit comments

Comments
 (0)