evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that parses various database connection configuration formats and extracts connection details into a standardized object structure.
postgresql://user:pass@localhost:5432/mydb, it extracts user as "user", password as "pass", host as "localhost", port as 5432, and database as "mydb" @testpostgres://admin@127.0.0.1/testdb, it extracts user as "admin", host as "127.0.0.1", and database as "testdb" with default port @testpostgres://user@host/db?sslmode=require&application_name=myapp, it extracts the SSL mode as "require" and application name as "myapp" in the configuration object @testpostgres://user@host/db?sslcert=/path/cert.pem&sslkey=/path/key.pem, it extracts SSL certificate and key paths in the configuration @test/var/run/postgresql mydb, it identifies the Unix socket path as "/var/run/postgresql" and database as "mydb" @testsocket:/tmp/pg.sock?db=testdb, it extracts the socket path and database name @testpostgres://user:p%40ssw0rd@host/db, it correctly decodes the password as "p@ssw0rd" @test/**
* Parses a database connection string and returns a configuration object.
*
* @param {string} connectionString - The connection string to parse (supports PostgreSQL URL format, Unix sockets)
* @returns {Object} Configuration object with connection details (user, password, host, port, database, ssl options, etc.)
* @throws {Error} Throws an error if the connection string format is invalid
*/
function parseConnectionString(connectionString) {
// IMPLEMENTATION HERE
}
module.exports = {
parseConnectionString
};Provides PostgreSQL client functionality and connection string parsing support.