Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
routington
Advanced tools
Routington is a trie-based URL router. Its goal is only to define and match URLs. It does not handle methods, headers, controllers, views, etc., in anyway. It is faster than traditional, linear, regular expression-matching routers, although insignficantly, and scales with the number of routes.
The purpose of this router isn't for performance, but to bring more structure to URL routing. The intention is for you to build a framework on top of it either on node.js or the browser.
For a node.js implementation, we have built connectington. This can be used either as a standalone or as a replacement for Express' router.
var routington = require('routington')
var router = routington()
router
is the root Node
in the trie. All node
s will have router
as furthest ancestor.
Every node on a tree is an instance of Node
. You only construct the root. node
on the other hand has the following properties:
child {}Node
- String based child definitions. For example, node.child['post']
will return a child node with node.string === 'post'
children []Node
- Name/regex based child definitionsparent Node
- The parent of the notename
- Name of the node (for parameter matching)string
- String to matchregex
- Regular expression to matchvar nodes = routington.define('/:identity(page|petition)/:id([0-9a-f]{24})')
route
is a definition of a route and is an extension of Express' routing syntax. route
, however, can only be a string.nodes
is an array of node
s.Each fragment of the route, delimited by a /
, can have the following signature:
string
- ex /post
string|string
- |
separated strings, ex /post|page
:name
- Wildcard route matched to a name(regex)
- A regular expression:name(regex)
- Named regular expression match:name(string|regex)
- Named regular expression or string matchEach node
of nodes
will always have node.string === ''
. URLs are always treated with a trailing /
by design.
You should always name your regular expressions otherwise you can't use the captured value. The regular expression is built using new RegExp('^(' + regex + ')$', 'i')
, so you need to escape your string, ie \\w
. You can always pre-define names or regular expressions before. For example, I can define:
router.define('/page/:id(\\w{3,30})')
// later, :id will have the same regexp
// so you don't have to repeat yourself
router.define('/page/:id/things')
router.define('/page/:id(\\w{3,30})')
var match = router.match('/page/taylorswift')
match
, unless null
, will be an object with the following properties:
param
- A list of named parameters, ex, match.param.id === 'taylorswift'
.node
- The matched node. Will have name.string === ''
IE9+
WTFPL
© Jonathan Ong 2013
FAQs
Trie-based URL Routing
The npm package routington receives a total of 169 weekly downloads. As such, routington popularity was classified as not popular.
We found that routington demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.