forked from sws-corp/site-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseConnection.js
More file actions
25 lines (21 loc) · 810 Bytes
/
parseConnection.js
File metadata and controls
25 lines (21 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// parseConnectionString.js
function parseConnectionString(connectionString) {
const regex = /postgresql:\/\/(.*?):(.*?)@/;
const match = connectionString.match(regex);
if (match) {
const username = match[1];
const password = match[2];
return { username, password };
} else {
return null;
}
}
// Replace the connection string with your actual one
const connectionString = 'postgresql://winniepot_owner:2dOjqGReUQy1@ep-damp-art-a2l58oqr-pooler.eu-central-1.aws.neon.tech/winniepot?sslmode=require';
const credentials = parseConnectionString(connectionString);
if (credentials) {
console.log(`Username: ${credentials.username}`);
console.log(`Password: ${credentials.password}`);
} else {
console.log('Invalid connection string');
}