Skip to content
Myr

Fix regression for empty string path in app.use

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

fixes #2361 fixes #2362

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 947fb8b · Browse files · 3 files+19 added−1 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+19 added−1 removed

  • tests:+12 added−0 removed
  • other:+7 added−1 removed

3 files+19 added−1 removed

modified:lib/application.js+2 added-1 removed
163 unmodified lines
164 while (Array.isArray(arg) && arg.length !== 0) {165 arg = arg[0];166 }167168 if (typeof arg !== 'function' && (arg == null || arg.length !== 0)) {168 // first arg is the path169 if (typeof arg !== 'function') {170 offset = 1;171 path = fn;172 }173 }
395 unmodified lines
modified:test/app.use.js+12 added
501 unmodified lines
502 request(app)503 .get('/get/zoo')504 .expect(404, cb);505 })506507 it('should support empty string path', function (done) {508 var app = express();509510 app.use('', function (req, res) {511 res.send('saw ' + req.method + ' ' + req.url + ' through ' + req.originalUrl);512 });513514 request(app)515 .get('/')516 .expect(200, 'saw GET / through /', done);517 })518 })519})
modified:History.md+5 added
1unreleased2==========34 * Fix regression for empty string `path` in `app.use`564.9.1 / 2014-09-167==================89 * Fix `app.use` to accept array of middleware without path
2249 unmodified lines