Skip to content
Myr

Added "case sensitive routes" option.

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

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent d2f963d · Browse files · 5 files+39 added−8 removed
This commit

State

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

Diff stats

5 files+39 added−8 removed

  • tests:+22 added−0 removed
  • other:+17 added−8 removed

5 files+39 added−8 removed

modified:docs/guide.md+1 added
81 unmodified lines
82 * _views_ Root views directory defaulting to **CWD/views**83 * _view engine_ Default view engine name for views rendered without extensions84 * _view options_ An object specifying global view options85 * _view cache_ Enable view caching (enabled in production)86 * _case sensitive routes_ Enable case-sensitive routing8788### Routing8990Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.
1252 unmodified lines
modified:lib/router/index.js+3 added-2 removed
32 unmodified lines
33 * @return {Function}34 * @api private35 */3637function router(fn){37function router(fn, app){38 var self = this39 , methods = {}40 , routes = {}41 , params = {};
41 unmodified lines
8384 if (!path) throw new Error(name + ' route requires a path');85 if (!fn) throw new Error(name + ' route ' + path + ' requires a callback');8687 var options = { sensitive: app.enabled('case sensitive routes') };87 var route = new Route(name, path, fn);88 var route = new Route(name, path, fn, options);89 localRoutes.push(route);90 return self;91 };92 }
238 unmodified lines
modified:lib/router/route.js+12 added-5 removed
modified:lib/http.js+1 added-1 removed
85 unmodified lines
86 // apply middleware87 if (middleware) middleware.forEach(self.use.bind(self));8889 // use router, expose as app.get(), etc90 var fn = router(function(app){ self.routes = app; });90 var fn = router(function(app){ self.routes = app; }, this);91 this.__defineGetter__('router', function(){92 this.__usedRouter = true;93 return fn;94 });
409 unmodified lines
modified:test/router.test.js+22 added
239 unmodified lines
240 app.match.get('/user/5/edit').should.have.length(2);241 app.match.get('/').should.have.be.empty;242 app.match.all('/user/123').should.have.length(3);243 app.match('/user/123').should.have.length(3);244 },245 246 'test "case sensitive routes" setting': function(){247 var app = express.createServer();248249 app.enable('case sensitive routes');250251 app.get('/account', function(req, res){252 res.send('account');253 });254 255 app.get('/Account', function(req, res){256 res.send('Account');257 });258259 assert.response(app,260 { url: '/account' },261 { body: 'account' });262263 assert.response(app,264 { url: '/Account' },265 { body: 'Account' });266 }267};