Parses MongoDB connection strings into structured objects. v3.0.3, stable but low maintenance. Differentiates from mongoose's parser by being standalone and simple, supporting both mongodb:// scheme and host-only formats. Returns {dbName, servers} with optional authentication and options fields. Ideal for CLI tools and lightweight MongoDB connection setups without full driver dependencies.
npm install mongodb-urlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic parsing of host:port, full URI with auth, and formatting config back to URL string.
Change to `import parse from 'mongodb-url'` or use named import `{ parse }` (named still works? Check docs). Actually v3 renamed the default export to parse, removing named 'parse'? From README: 'var parse = require('mongodb-url')' suggests default export is parse. Named 'parse' may not exist. Safer: use default import.Filter options to only standard connection string options before passing to MongoClient.
Always include a database name in the URI, e.g., `mongodb://localhost:27017/mydb`.
Use `import parse from 'mongodb-url'` (v3+) or `const parse = require('mongodb-url')` for CommonJS.Run `npm install mongodb-url` and check that package.json includes it.
Ensure dbName is a string (default 'admin' if omitted, but explicitly set it).