# redis-url-parse

> Spread a Redis URL string into a configuration object.

Latest version **2.0.0** (published 2018-10-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install redis-url-parse
pnpm add redis-url-parse
yarn add redis-url-parse
bun add redis-url-parse
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-10-24 |
| First published | 2017-04-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.13.0 |
| Dependencies | 0 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Chris Chang |
| Maintainers | crccheck |
| Keywords | redis, 12factor, dsn |

## Links

- npm: https://www.npmjs.com/package/redis-url-parse
- Repository: https://github.com/crccheck/redis-url-parse
- Homepage: https://github.com/crccheck/redis-url-parse#readme
- Issues: https://github.com/crccheck/redis-url-parse/issues
- npm.io page: https://npm.io/package/redis-url-parse

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-10-24
- 1.0.2 — 2017-04-07
- 1.0.1 — 2017-04-06
- 1.0.0 — 2017-04-06

## README

Redis URL Parse
===============

[![Build Status](https://travis-ci.org/crccheck/redis-url-parse.svg?branch=master)](https://travis-ci.org/crccheck/redis-url-parse)
[![npm version](https://badge.fury.io/js/redis-url-parse.svg)](https://badge.fury.io/js/redis-url-parse)

Spread a Redis URL string into a configuration object.

Module usage
------------

```javascript
const redisUrlParse = require('redis-url-parse')

// Defaults to localhost:6379/0
redisUrlParse('redis://')
//=> {host: 'localhost', port: 6379, database: '0', password: undefined}

// But you can change databases by adding a path
redisUrlParse('redis:///1')
//=> {host: 'localhost', port: 6379, database: '1', password: undefined}

// And change hosts
redisUrlParse('redis://example.com:39143/')
//=> {host: 'example.com', port: 39143, database: '0', password: undefined}

// And even add passwords
redisUrlParse('redis://:n9y25ah7@example.com:39143/')
//=> {host: 'example.com', port: 39143, database: '0', password: 'n9y25ah7'}

// If you add a username, it's ignored
redisUrlParse('redis://user:hunter2@example.com:39143/')
//=> {host: 'example.com', port: 39143, database: '0', password: 'hunter2'}

// If your password uses special characters, you may need to URI encode it
redisUrlParse('redis://:my%3Asuper%21secure%3Fpassword@example.com:39143/')
//=> {host: 'example.com', port: 39143, database: '0', password: 'my:super!secure?password'}
```


Complete example
----------------

```
const redisUrlParse = require('redis-url-parse')
redisUrlParse(process.env.REDIS_URL)  // redis://
//=> {host: 'localhost', port: 6379, database: '0', password: undefined}
```


Prior art
---------

* [parse-redis-url](https://github.com/laggyluke/node-parse-redis-url) not maintained and has an extremely awkward interface `require('parse-redis-url')(null).parse(url)`
* [redis-url](https://github.com/ddollar/redis-url) not maintained and requires `redis` as a requirement
* [redis-url-parser](https://github.com/cilindrox/redis-url-parser) not maintained and only works if your URL has a password

---
_Source: https://npm.io/package/redis-url-parse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
