Skip to content
Reversing routes for express and browser. Like a Rails or Flask url_for method.
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md
index.js
package.json
test.js

README.md

url4

Reversing routes for Express and browser. Like a Rails or Flask url_for method.

Install

npm install url4

Tests

npm test

Usage

var assert = require('assert');
var url4 = require('url4');

url4.urls = {
  index: '/',
  users: '/users/:id?'
};

var url = url4('index');
assert.equal(url, '/');

var url = url4('users');
assert.equal(url, '/users');

var url = url4('users', {'id': 'foo'});
assert.equal(url, '/users/foo');
Something went wrong with that request. Please try again.