Skip to content

Instantly share code, notes, and snippets.

@pujianto
Created January 11, 2022 19:27
Show Gist options
  • Save pujianto/b73ebd487a8fb32ede67d289549f15e4 to your computer and use it in GitHub Desktop.
Save pujianto/b73ebd487a8fb32ede67d289549f15e4 to your computer and use it in GitHub Desktop.
Get database name from Mongo/Mysql URL
// dbUrl example: mongodb://user:[email protected]/MyDB?authsource=admin
const getDatabaseName = (dbUrl) => url.parse(dbUrl).pathname.substring(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment