Skip to content

Commit 5e3d517

Browse files
authored
Merge pull request #21 from lightfallphotos/master
Allow URL encoded host in parseDSN
2 parents ad45c41 + 3e6add1 commit 5e3d517

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/utilities/parseDsn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const parseDsn = (dsn: string): ConnectionOptions => {
2222
const connectionOptions: ConnectionOptions = {};
2323

2424
if (url.host) {
25-
connectionOptions.host = url.hostname;
25+
connectionOptions.host = decodeURIComponent(url.hostname);
2626
}
2727

2828
if (url.port) {

test/slonik/utilities/parseDsn.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ test('postgresql://fo%2Fo:b%2Far@localhost/ba%2Fz', testParse, {
4545
password: 'b/ar',
4646
username: 'fo/o',
4747
});
48+
test('postgresql://db_user:db_password@%2Fcloudsql%2Fproject-id%3Aregion-id1%3Acloudsqlinstance-name/dbname', testParse, {
49+
databaseName: 'dbname',
50+
host: '/cloudsql/project-id:region-id1:cloudsqlinstance-name',
51+
password: 'db_password',
52+
username: 'db_user',
53+
});

0 commit comments

Comments
 (0)