reverend

Merge an express-style path string with data to create a valid path.

supplanted by path-to-regexp@v1.1.0#compile
Last updated 12 years ago by jasisk .
Apache 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install reverend 
SYNC missed versions from official npm registry.

DEPRECATED: Reverend has been deprecated and will no longer see updates. The underlying module used to create regular expressions from routes—path-to-regexp—has added reverse-routing functionality. Please favor it over Reverend. An api-compatible shim can be seen in the shim branch.

reverend

Lead Maintainer: Jean-Charles Sisk

Build Status

Merge an express-style path string with data to create a valid path. Version 0.3.x adds support for Custom Match and Unnamed parameters as provided by path-to-regexp ^0.2.0. To ensure compatibility, use the version of reverend compatible with path-to-regexp which most closely matches the version your application uses.

Usage

var reverend = require('reverend');

reverend(path, object);

  • path (String|Array) - An express-style path, or an array of paths, of which only the first element will be used.
  • object (Object) - An object with keys matching the tokens to be replaced in the route.
'use strict';

var reverend = require('reverend');


var path;

// Path params
path = reverend('/user/:id', { id: 5 });
// '/user/5';

// Optional path params
path = reverend('/user/:id/:operation?', { id: 5 });
// '/user/5/';

// Multiple path params
path = reverend('/user/:id/:operation', { id: 5, operation: address });
// '/user/5/address';

// Custom match parameters
path = reverend('/posts/:id(\\d+)', { id: 5 });
// '/post/5'

path = reverend('/posts/:id(\\d+)', { id: 'foo' }); // throws

// Unnamed params
path = reverend('/:foo/(.*)', { foo: 'foo', 0: 'bar' });
// '/foo/bar'

License

MIT

Tests, Coverage, Linting

$ npm test
$ npm run cover
$ npm run lint

Current Tags

  • 0.3.1                                ...           latest (12 years ago)

4 Versions

  • 0.3.1 [deprecated]           ...           12 years ago
  • 0.3.0 [deprecated]           ...           12 years ago
  • 0.2.0 [deprecated]           ...           13 years ago
  • 0.1.0 [deprecated]           ...           13 years ago
Maintainers (2)
Downloads
Total 11
Today 0
This Week 2
This Month 11
Last Day 0
Last Week 9
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE