Skip to content
Myr

Fix req.next when inside router instance

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fixes #2016

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent e4302b2 · Browse files · 3 files+43 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+43 added−5 removed

  • tests:+21 added−0 removed
  • other:+22 added−5 removed

3 files+43 added−5 removed

modified:lib/router/index.js+21 added-5 removed
5 unmodified lines
6var Layer = require('./layer');7var methods = require('methods');8var debug = require('debug')('express:router');9var parseUrl = require('parseurl');10var slice = Array.prototype.slice;1112/**13 * Initialize a new `Router` with the given `options`.14 *
114 unmodified lines
129130 // middleware and routes131 var stack = self.stack;132133 // request-level next134 var parent = req.next;135 done = wrap(done, function(old, err) {136 req.next = parent;137 old(err);138 });139 req.next = next;140141 // for options requests, respond with a default if nothing else responds142 if (method === 'options') {134 var old = done;135 done = function(err) {143 done = wrap(done, function(old, err) {144 if (err || options.length === 0) return old(err);145146 var body = options.join(',');147 return res.set('Allow', body).send(body);140 };148 });149 }150151 next();152143 (function next(err) {153 function next(err) {154 if (err === 'route') {155 err = undefined;156 }157
83 unmodified lines
241 } else {242 next(err);243 }244 }245 }246236 })();247 function wrap(old, fn) {248 return function () {249 var args = [old].concat(slice.call(arguments));250 fn.apply(this, args);251 };252 }253};254255/**256 * Process any parameters for the route.
145 unmodified lines
modified:test/res.format.js+21 added
modified:History.md+1 added
14.2.x2=====34 * fix `req.next` when inside router instance5 * include `ETag` header in `HEAD` requests6 * keep previous `Content-Type` for `res.jsonp`784.1.2 / 2014-05-08
1357 unmodified lines