Regex Postgres Connection String (#3746)

* Regex Postgres Connection String

* Fix regex

* Fix indentation

* Indentation

---------

Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
Henri Courdent
2024-11-03 02:54:53 +01:00
committed by GitHub
parent ea40331ab7
commit 372f5f4335
@@ -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