Registry / database / redisuri

redisuri

JSON →
library1.1.2jsnpmunverified

Validate and parse Redis URI connection schemes. Current stable version is 1.1.2. The package provides two functions: parse() to break a Redis URI into auth, host, port, and db components, and validate() to check protocol and host presence. It is a simple, zero-dependency utility for handling Redis connection strings. Release cadence is low; last update was several years ago. Differentiators: lightweight, no external dependencies, explicit validation of URI format.

npm install redisuri
INSTALL
IMPORT
SIG · REDISURI
R
redisuri
databasejavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'redisuri'
import parse from 'redisuri'
Package exports both functions as named exports
validate
import { validate } from 'redisuri'
const validate = require('redisuri').validate
CommonJS require works but ESM named import is preferred
redisuri (default)
import * as redisuri from 'redisuri'
import redisuri from 'redisuri'
There is no default export; use namespace import to get both functions

Demonstrates parsing a Redis URI with authentication, custom host, port, and database number, including validation.

import { parse, validate } from 'redisuri'; const uri = 'redis://authstring@192.168.1.1:6379/7'; try { const valid = validate(uri); console.log('Valid URI:', valid); const parsed = parse(uri); console.log(parsed); // => { auth: 'authstring', host: '192.168.1.1', port: 6379, db: 7 } } catch (err) { console.error(err); }
Debug
Known issues
gotchaparse() returns port as number and db as number, but auth and host are strings. Ensure type consistency when using the output.
fix
Check types before using: auth is string|null; host is string; port and db are numbers.
affects: >=0.0.0
gotchavalidate() throws TypeError on invalid input; it does not return boolean. Code must wrap in try/catch or use instanceof check.
fix
Use try/catch around validate() or call parse() directly which also validates and returns parsed object or throws.
affects: >=0.0.0
gotchaThe package does not support Redis Sentinel or TLS URIs (e.g., rediss://). Only plain redis:// scheme is handled.
fix
If you need Sentinel or TLS support, consider using ioredis's built-in URI parsing or a more comprehensive library.
affects: >=0.0.0
gotchaThe auth string is extracted from the URI, but the package does not URL-decode percent-encoded characters (e.g., %40 for @).
fix
Pre-decode the auth string if necessary: decodeURIComponent(uri).
affects: >=0.0.0
gotchaparse() returns db as a number; if the URI has no database, default is 0. But if database is invalid (e.g., non-numeric), it returns NaN.
fix
Validate that the database segment is a number before trusting the output.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: A protocol must be specified in the Redis URI connection scheme (e.g. redis:)
Passing a URI without the 'redis://' protocol to validate() or parse().
fix
Ensure URI starts with 'redis://'. Example: const uri = 'redis://localhost:6379';
TypeError: A host must be specified in the Redis URI connection scheme
Passing a URI without a hostname after the protocol, like 'redis://:6379'.
fix
Provide a valid hostname, e.g., 'redis://localhost:6379'.
ReferenceError: redisuri is not defined
Trying to use the package without importing or requiring it.
fix
Add import: import { parse, validate } from 'redisuri'; (ESM) or const redisuri = require('redisuri'); (CJS).
TypeError: redisuri.parse is not a function
Incorrect import style: using default import when the package has named exports.
fix
Use named imports: import { parse, validate } from 'redisuri';
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Meta
1
Resources
redisuri — npm install redisuri · libregistry