Skip to content

Commit

Permalink
Regex Postgres Connection String (#3746)
Browse files Browse the repository at this point in the history
* Regex Postgres Connection String

* Fix regex

* Fix indentation

* Indentation

---------

Co-authored-by: Ruben Fiszel <[email protected]>
  • Loading branch information
hcourdent and rubenfiszel authored Nov 3, 2024
1 parent ea40331 commit 372f5f4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions frontend/src/lib/components/ApiConnectForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@
let connectionString = ''
let validConnectionString = true
function parseConnectionString(close: (_: any) => void) {
// parse postgres connection string
const regex =
/postgres:\/\/(?<user>[^:@]+)(?::(?<password>[^@]+))?@(?<host>[^:\/?]+)(?::(?<port>\d+))?\/(?<dbname>[^\?]+)?(?:\?.*sslmode=(?<sslmode>[^&]+))?/
/postgres(?:ql)?:\/\/(?<user>[^:@]+)(?::(?<password>[^@]+))?@(?<host>[^:\/?]+)(?::(?<port>\d+))?\/(?<dbname>[^\?]+)?(?:\?.*sslmode=(?<sslmode>[^&]+))?/
const match = connectionString.match(regex)
if (match) {
validConnectionString = true
Expand Down

0 comments on commit 372f5f4

Please sign in to comment.