UNPKG

copybase

Version:

Copy or backup databases quickly

22 lines (21 loc) 690 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseDatabaseUri = parseDatabaseUri; function parseDatabaseUri(uri) { var _a, _b; try { const url = new URL(uri); return { hostname: url.hostname, password: url.password, username: url.username, protocol: (_a = url.protocol) === null || _a === void 0 ? void 0 : _a.replace(":", ""), database: (_b = url.pathname) === null || _b === void 0 ? void 0 : _b.replace("/", ""), port: url.port, params: Object.fromEntries(url.searchParams), }; } catch (err) { return null; } }