crossing

1.2.1 • Public • Published

Crossing

Crossing is JavaScript URL utility library that aims to help you manage and generate dynamic urls.

browser support

Install

npm install crossing

Basic Use

 
  var Crossing = require('crossing');
 
  // create your crossing instance
  var urls = new Crossing();
 
  // load your url list
  urls.load({
    'team:detail': '/teams/<slug>/',
    'discussion:detail': '/<team_slug>/<discussion_id>/<slug>/',
    'search': '/search/'
  });
 
  // get a url
  var path = urls.get('team:detail', {'slug': 'lincolnloop'}); // -> /teams/lincolnloop/
 
  // resolve a path to get the url name and attrs
  var urlName = urls.resolve('/loop/23/discussion-name/'); // -> {'name': 'discussion:detail', 'kwargs': {'team_slug': 'loop', 'discussion_id': 23, 'slug': 'discussion-name'}}
 

That's all there is to it! Enjoy!

Run Tests

npm test

Readme

Keywords

Package Sidebar

Install

npm i crossing

Weekly Downloads

523

Version

1.2.1

License

MIT

Last publish

Collaborators

  • mlouro
  • unbracketed