@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
24 lines (23 loc) • 940 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseConnectionString = void 0;
const connection_string_parser_1 = require("connection-string-parser");
/**
* Parses a PostgreSQL connection string.
* Accepts both postgres:// and postgresql:// schemes and normalizes to postgresql://
*
* @param connectionString - The connection string to parse (e.g., "postgresql://user:pass@localhost:5432/dbname")
* @returns Parsed connection string parameters
*/
function parseConnectionString(connectionString) {
const parser = new connection_string_parser_1.ConnectionStringParser({
scheme: "postgresql",
hosts: []
});
// Normalize postgres:// to postgresql:// (the official IANA scheme)
const normalizedConnectionString = connectionString.replace(/^postgres:\/\//, "postgresql://");
return parser.parse(normalizedConnectionString);
}
exports.parseConnectionString = parseConnectionString;