Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

more-router

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

more-router

Router library. Derived from Morepath.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

more-route

Introduction

more-route is a routing library. It can run both on the client as well as on the server.

Its possibly special qualities include:

  • it has a precedence system: given the pattern /foo and the pattern /{myvariable}, the path /foo will match the pattern /foo, not the variable.

  • you mix text and variables in a single segment: /prefix{variable}

Usage

  var Router = require('more-router');

  var router = new Router();

  // second argument can be anything you like; here we use a string
  // for easy demonstration of the API
  router.addPattern('a', 'found a');
  router.addPattern('a/{v}', 'found a/{v}')

  router.resolve('a')
  // returns
  // {
  //   value: "found a",
  //   stack: [],
  //   variables: {}
  // }

  router.resolve('a/foo')
  // returns
  // {
  //   value: "found a/{v}",
  //   stack: [],
  //   variables: {'v': 'foo'}
  // }

  // alternate consume interface which taxes a stack
  router.consume(['foo', 'a'])
  // returns
  // {
  //   value: "found a/{v}",
  //   stack: [],
  //   variables: {'v': 'foo'}
  // }

  // if no match exists, value is null, unmatched segments are on stack
  router.resolve('notthere')
  // returns
  // {
  //   value: null,
  //   stack: ['notthere'],
  //   variables: {}
  // }

Background

more-route is derived from the routing code in the Morepath web framework written in Python.

Keywords

FAQs

Package last updated on 19 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc