Skip to content
Myr

Added "strict routing" setting for trailing slashes

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

for people who are: a) over-optimizing seo b) working on fs-like APIs

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 4b9cc3d · Browse files · 4 files+35 added−6 removed
This commit

State

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

Diff stats

4 files+35 added−6 removed

  • tests:+23 added−1 removed
  • other:+12 added−5 removed

4 files+35 added−6 removed

modified:docs/guide.md+1 added
102 unmodified lines
103 * _view engine_ Default view engine name for views rendered without extensions104 * _view options_ An object specifying global view options105 * _view cache_ Enable view caching (enabled in production)106 * _case sensitive routes_ Enable case-sensitive routing107 * _strict routing_ When enabled trailing slashes are no longer ignored108109### Routing110111Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.
1296 unmodified lines
modified:lib/router/index.js+1 added
371 unmodified lines
372373 // create the route374 var route = new Route(method, path, fn, {375 sensitive: app.enabled('case sensitive routes')376 , strict: app.enabled('strict routing')377 , middleware: middleware378 });379380 // add it
4 unmodified lines
modified:lib/router/route.js+10 added-5 removed
modified:test/router.test.js+23 added-1 removed
315 unmodified lines
316 ret.should.have.length(3);317 app.match.all('/user/12').should.have.length(0);318 app.get('/user/:id').should.have.length(0);319 },320 320321 'test "strict routing" setting': function(){322 var app = express.createServer();323324 app.enable('strict routing');325326 app.get('/:path', function(req, res, next){327 res.send({ type: 'directory' });328 });329330 app.get('/:path/', function(req, res, next){331 res.send(['.', '..', 'foo.js', 'bar.js']);332 });333334 assert.response(app,335 { url: '/lib' },336 { body: '{"type":"directory"}' });337338 assert.response(app,339 { url: '/lib/' },340 { body: '[".","..","foo.js","bar.js"]' });341 },342343 'test "case sensitive routes" setting': function(){344 var app = express.createServer();345346 app.enable('case sensitive routes');
61 unmodified lines