Skip to content

Commit f4a367a

Browse files
authored
fix: Make sure we uri encode credentials and db name (#7)
1 parent e718495 commit f4a367a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cmd-database-url.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ async function resolveUrl(resourceName: string) {
1616

1717
let credentials = ''
1818
if (dbInfo.credentials?.username) {
19-
credentials += dbInfo.credentials.username;
19+
credentials += encodeURIComponent(dbInfo.credentials.username);
2020

2121
if (dbInfo.credentials.password) {
22-
credentials += ':' + dbInfo.credentials.password;
22+
credentials += ':' + encodeURIComponent(dbInfo.credentials.password);
2323
}
2424
}
2525

26-
return `mongodb://${credentials}@${dbInfo.host}:${dbInfo.port}/${dbName}?authSource=admin&directConnection=true`;
26+
return `mongodb://${credentials}@${dbInfo.host}:${dbInfo.port}/${encodeURIComponent(dbName)}?authSource=admin&directConnection=true`;
2727
}
2828

2929
if (!process.argv[2]) {

0 commit comments

Comments
 (0)