Skip to content
Myr

Clean up code and syntax issues.

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

authored by Blake Embrey · committed by Blake Embrey · parent 9ae1d0d · Browse files · 3 files+13 added−16 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+13 added−16 removed

  • tests:+6 added−7 removed
  • other:+7 added−9 removed

3 files+13 added−16 removed

modified:lib/router/index.js+5 added-7 removed
168 unmodified lines
169 var route = layer.route;170171 // if final route, then we support options172 if (route) {173 // we don't run any routs with error first173 // we don't run any routes with error first174 if (err) {175 return next(err);176 }177
140 unmodified lines
318 * @api public319 */320321proto.use = function(route, fn){322322 // default route to '/'323 if ('string' != typeof route) {324 fn = route;325 route = '/';
9 unmodified lines
335 if ('/' == route[route.length - 1]) {336 route = route.slice(0, -1);337 }338340 var layer = Layer(route, {339 var layer = new Layer(route, {340 sensitive: this.caseSensitive,341 strict: this.strict,342 end: false343 }, fn);
20 unmodified lines
364365proto.route = function(path){366 var route = new Route(path);367369 var layer = Layer(path, {368 var layer = new Layer(path, {369 sensitive: this.caseSensitive,370 strict: this.strict,371 end: true372 }, route.dispatch.bind(route));
6 unmodified lines
379380// create Router#VERB functions381methods.concat('all').forEach(function(method){382 proto[method] = function(path, fn){384 var self = this;385 self.route(path)[method](fn);386 return self;383 this.route(path)[method](fn);384 return this;385 };386});387
modified:lib/router/route.js+2 added-2 removed
modified:test/Router.js+6 added-7 removed
3 unmodified lines
4 , methods = require('methods')5 , assert = require('assert');67describe('Router', function(){88 it('should return a function with router methods', function() {9 var router = Router();10 assert(typeof router == 'function');11
4 unmodified lines
16 assert(typeof router.handle == 'function');17 assert(typeof router.use == 'function');18 });1921 it('should support .use of other routers', function(done) {22 var router = Router();23 var another = Router();20 it('should support .use of other routers', function(done){21 var router = new Router();22 var another = new Router();2325 another.get('/bar', function(req, res) {26 res.done();24 another.get('/bar', function(req, res){25 res.end();26 });27 router.use('/foo', another);2830 router.handle({ url: '/foo/bar', method: 'GET' }, { done: done });29 router.handle({ url: '/foo/bar', method: 'GET' }, { end: done });30 });3132 it('should support dynamic routes', function(done){33 var router = new Router();
136 unmodified lines