Utility library for parsing, building, and manipulating MongoDB connection strings. Current stable version is 0.1.5. It provides a ConnectionString class to decompose URIs into components (protocol, username, password, hosts, database, options) and serialize them back to URI or human-readable form. The library handles URL encoding/decoding, defaults protocol to mongodb://, and includes a heuristic for percent-encoded characters. It is actively maintained but rarely updated. Key differentiators: lightweight with TypeScript types, no dependencies, designed for both Node.js and browser, and provides a safe toString() that masks passwords.
npm install mongo-connection-stringNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Parse a MongoDB connection string, access its components, and serialize back to URI or safe log string.
Always include protocol, e.g., 'mongodb://localhost'.
If your password contains '%' that is not part of percent-encoding, escape it properly or encode it manually.
Use 'new ConnectionString(input)' instead.
Ensure port is a number, not a string.
Use import { ConnectionString } from 'mongo-connection-string' or const { ConnectionString } = require('mongo-connection-string')Run npm install mongo-connection-string and ensure Node version >= 8.5.0
No dependency data recorded yet.