Skip to content

Commit

Permalink
fix(migrations): encode input to ensure valid postgres urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Intellicode committed Dec 13, 2024
1 parent 8c2e2e3 commit 5630680
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/migrations/src/connection-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ export function createConnectionString(config: {
ssl: boolean;
}) {
// prettier-ignore
return `postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.db}${config.ssl ? '?sslmode=require' : '?sslmode=disable'}`;
const encodedUser = encodeURIComponent(config.user);
const encodedPassword = encodeURIComponent(config.password);
const encodedHost = encodeURIComponent(config.host);
const encodedDb = encodeURIComponent(config.db);

return `postgres://${encodedUser}:${encodedPassword}@${encodedHost}:${config.port}/${encodedDb}${config.ssl ? '?sslmode=require' : '?sslmode=disable'}`;
}

0 comments on commit 5630680

Please sign in to comment.