Skip to content
Myr

Fix incorrect middleware execution with unanchored RegExps

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

fixes #4204 closes #4205

authored by Ivan Derevianko · committed by Douglas Christopher Wilson · parent a1dbb11 · Browse files · 3 files+36 added−0 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+36 added−0 removed

  • tests:+29 added−0 removed
  • other:+7 added−0 removed

3 files+36 added−0 removed

modified:lib/router/index.js+6 added
285 unmodified lines
286 }287288 function trim_prefix(layer, layerError, layerPath, path) {289 if (layerPath.length !== 0) {290 // Validate path is a prefix match291 if (layerPath !== path.substr(0, layerPath.length)) {292 next(layerError)293 return294 }295296 // Validate path breaks on a path separator297 var c = path[layerPath.length]298 if (c && c !== '/' && c !== '.') return next(layerError)299
369 unmodified lines
modified:test/app.router.js+29 added
184 unmodified lines
185 request(app)186 .get('/user/10/edit')187 .expect('editing user 10', done);188 })189190 it('should ensure regexp matches path prefix', function (done) {191 var app = express()192 var p = []193194 app.use(/\/api.*/, function (req, res, next) {195 p.push('a')196 next()197 })198 app.use(/api/, function (req, res, next) {199 p.push('b')200 next()201 })202 app.use(/\/test/, function (req, res, next) {203 p.push('c')204 next()205 })206 app.use(function (req, res) {207 res.end()208 })209210 request(app)211 .get('/test/api/1234')212 .expect(200, function (err) {213 if (err) return done(err)214 assert.deepEqual(p, ['c'])215 done()216 })217 })218 })219220 describe('case sensitivity', function(){221 it('should be disabled by default', function(done){
886 unmodified lines
modified:History.md+1 added
1unreleased2==========34 * Fix incorrect middleware execution with unanchored `RegExp`s5 * Fix `res.jsonp(obj, status)` deprecation message6 * Fix typo in `res.is` JSDoc7 * deps: proxy-addr@~2.0.68 - deps: ipaddr.js@1.9.1
3478 unmodified lines