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

router

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

router - npm Package Compare versions

Comparing version 1.0.0-beta.3 to 1.0.0

8

HISTORY.md

@@ -0,1 +1,8 @@

1.0.0 / 2015-01-13
==================
* Fix crash from error within `OPTIONS` response handler
* deps: array-flatten@1.0.2
- Remove redundant code path
1.0.0-beta.3 / 2015-01-11

@@ -7,2 +14,3 @@ =========================

* Remove support for leading colon in `router.param(name, fn)`
* Use `array-flatten` for flattening arrays
* deps: debug@~2.1.1

@@ -9,0 +17,0 @@ * deps: methods@~1.1.1

60

index.js

@@ -14,2 +14,3 @@ /*!

var debug = require('debug')('router')
var flatten = require('array-flatten')
var Layer = require('./lib/layer')

@@ -20,3 +21,2 @@ var methods = require('methods')

var Route = require('./lib/route')
var utils = require('./lib/utils')

@@ -464,3 +464,3 @@ /**

var callbacks = utils.flatten(slice.call(arguments, offset))
var callbacks = flatten(slice.call(arguments, offset))

@@ -548,18 +548,3 @@ if (callbacks.length === 0) {

var options = Object.create(null)
// build unique method map
for (var i = 0; i < methods.length; i++) {
options[methods[i]] = true
}
// construct the allow list
var allow = Object.keys(options).sort().join(', ')
// send response
res.setHeader('Allow', allow)
res.setHeader('Content-Length', Buffer.byteLength(allow))
res.setHeader('Content-Type', 'text/plain')
res.setHeader('X-Content-Type-Options', 'nosniff')
res.end(allow)
trySendOptionsResponse(res, methods, fn)
}

@@ -689,2 +674,41 @@ }

/**
* Send an OPTIONS response.
*
* @private
*/
function sendOptionsResponse(res, methods) {
var options = Object.create(null)
// build unique method map
for (var i = 0; i < methods.length; i++) {
options[methods[i]] = true
}
// construct the allow list
var allow = Object.keys(options).sort().join(', ')
// send response
res.setHeader('Allow', allow)
res.setHeader('Content-Length', Buffer.byteLength(allow))
res.setHeader('Content-Type', 'text/plain')
res.setHeader('X-Content-Type-Options', 'nosniff')
res.end(allow)
}
/**
* Try to send an OPTIONS response.
*
* @private
*/
function trySendOptionsResponse(res, methods, next) {
try {
sendOptionsResponse(res, methods)
} catch (err) {
next(err)
}
}
/**
* Wrap a function

@@ -691,0 +715,0 @@ *

@@ -14,7 +14,14 @@ /*!

var debug = require('debug')('router:route')
var flatten = require('array-flatten')
var Layer = require('./layer')
var methods = require('methods')
var utils = require('./utils')
/**
* Module variables.
* @private
*/
var slice = Array.prototype.slice
/**
* Expose `Route`.

@@ -163,3 +170,3 @@ */

Route.prototype.all = function all(handler) {
var callbacks = utils.flatten([].slice.call(arguments))
var callbacks = flatten(slice.call(arguments))

@@ -187,3 +194,3 @@ if (callbacks.length === 0) {

Route.prototype[method] = function (handler) {
var callbacks = utils.flatten([].slice.call(arguments))
var callbacks = flatten(slice.call(arguments))

@@ -190,0 +197,0 @@ if (callbacks.length === 0) {

{
"name": "router",
"description": "Simple middleware-style router",
"version": "1.0.0-beta.3",
"version": "1.0.0",
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",

@@ -9,2 +9,3 @@ "license": "MIT",

"dependencies": {
"array-flatten": "1.0.2",
"debug": "~2.1.1",

@@ -11,0 +12,0 @@ "methods": "~1.1.1",

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