urlpattern

Parse and transform URL patterns.

urlpattern

Parse and transform URL patterns.

$ npm install urlpattern

Parse a pattern into a RegExp, and its constituent placeholders.

var pattern = require('urlpattern').express;
 
var placeholders = [];
var regexp = pattern.parse('/user/:id', placeholders);

Subsitute variables into a pattern.

var pattern = require('urlpattern').express;
 
pattern.transform('/user/:id', { id: '1234' });
// => '/user/1234' 
$ npm install
$ npm test

The MIT License

Copyright (c) 2013 Jared Hanson <http://jaredhanson.net/>