TypeScript Parse Database Url
Install
$ npm i ts-parse-database-url
Usage
import parseDatabaseUrl from 'ts-parse-database-url';
const dbUrl = 'mysql://someuser@server.heroku.com:1337/herokudb'
const parsed = parseDatabaseUrl(dbUrl)
/**
* parsed = {
* 'driver': 'mysql',
* 'user': 'someuser',
* 'host': 'server.heroku.com',
* 'port': '1337',
* 'database': 'herokudb'
* }
*/
Look at src/__tests__
for more tests examples.
Thanks to https://github.com/pwnall/node-parse-database-url for creating the original lib :tada: