Socket
Socket
Sign inDemoInstall

router

Package Overview
Dependencies
8
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

9

HISTORY.md

@@ -0,1 +1,10 @@

1.3.0 / 2017-02-25
==================
* Add `next("router")` to exit from router
* Fix case where `router.use` skipped requests routes did not
* Use `%o` in path debug to tell types apart
* deps: setprototypeof@1.0.3
* perf: add fast match path for `*` route
1.2.0 / 2017-02-17

@@ -2,0 +11,0 @@ ==================

26

index.js

@@ -209,2 +209,8 @@ /*!

// signal to exit router
if (layerError === 'router') {
defer(done, null)
return
}
// no more matching layers

@@ -299,12 +305,12 @@ if (idx >= stack.length) {

function trim_prefix(layer, layerError, layerPath, path) {
var c = path[layerPath.length]
if (layerPath.length !== 0) {
// Validate path breaks on a path separator
var c = path[layerPath.length]
if (c && c !== '/') {
next(layerError)
return
}
if (c && c !== '/') {
next(layerError)
return
}
// Trim off the part of the url that matches the route
// middleware (.use stuff) needs to have the path stripped
if (layerPath.length !== 0) {
// Trim off the part of the url that matches the route
// middleware (.use stuff) needs to have the path stripped
debug('trim prefix (%s) from url %s', layerPath, req.url)

@@ -477,3 +483,3 @@ removed = layerPath

// add the middleware
debug('use %s %s', path, fn.name || '<anonymous>')
debug('use %o %s', path, fn.name || '<anonymous>')

@@ -480,0 +486,0 @@ var layer = new Layer(path, {

@@ -36,3 +36,3 @@ /*!

debug('new %s', path)
debug('new %o', path)
var opts = options || {}

@@ -46,5 +46,5 @@

if (path === '/' && opts.end === false) {
this.regexp.fast_slash = true
}
// set fast path flags
this.regexp.fast_star = path === '*'
this.regexp.fast_slash = path === '/' && opts.end === false
}

@@ -114,4 +114,4 @@

if (path != null) {
// fast path non-ending match for / (any path matches)
if (this.regexp.fast_slash) {
// fast path non-ending match for / (any path matches)
this.params = {}

@@ -122,2 +122,9 @@ this.path = ''

// fast path for * (everything matched in a param)
if (this.regexp.fast_star) {
this.params = {'0': decode_param(path)}
this.path = path
return true
}
// match the path

@@ -124,0 +131,0 @@ match = this.regexp.exec(path)

@@ -41,3 +41,3 @@ /*!

function Route(path) {
debug('new %s', path)
debug('new %o', path)
this.path = path

@@ -113,2 +113,3 @@ this.stack = []

function next(err) {
// signal to exit route
if (err && err === 'route') {

@@ -118,2 +119,7 @@ return done()

// signal to exit router
if (err && err === 'router') {
return done(err)
}
// no more matching layers

@@ -120,0 +126,0 @@ if (idx >= stack.length) {

{
"name": "router",
"description": "Simple middleware-style router",
"version": "1.2.0",
"version": "1.3.0",
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
"contributors": [
"Blake Embrey <hello@blakeembrey.com>"
],
"license": "MIT",

@@ -14,3 +17,3 @@ "repository": "pillarjs/router",

"path-to-regexp": "0.1.7",
"setprototypeof": "1.0.2",
"setprototypeof": "1.0.3",
"utils-merge": "1.0.0"

@@ -17,0 +20,0 @@ },

@@ -77,2 +77,5 @@ # router

[Middleware](#middleware) can themselves use `next('router')` at any time to
exit the current router instance completely, invoking the top-level callback.
### router\[method](path, ...[middleware], handler)

@@ -99,2 +102,5 @@

Route handlers and middleware can themselves use `next('router')` at any time
to exit the current router instance completely, invoking the top-level callback.
### router.param(name, param_middleware)

@@ -101,0 +107,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc