Skip to content
Myr

fix behavior of multiple app.VERB for the same path

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

fixes #2116

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 8fe8d74 · Browse files · 3 files+58 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

3 files+58 added−8 removed

  • tests:+22 added−1 removed
  • other:+36 added−7 removed

3 files+58 added−8 removed

modified:lib/application.js+35 added-7 removed
28 unmodified lines
29 * @api private30 */3132app.init = function(){33 this._baseRoutes = {};34 this.cache = {};35 this.settings = {};36 this.engines = {};37 this.defaultConfiguration();
361 unmodified lines
399 */400401methods.forEach(function(method){402 app[method] = function(path){402 if ('get' == method && 1 == arguments.length) return this.set(path);403 if (method === 'get' && arguments.length === 1) {404 return this.set(path);405 }406404 this.lazyrouter();405406 var route = this._router.route(path);407 var route = this._baseRoute(path);408 route[method].apply(route, [].slice.call(arguments, 1));409 return this;410 };411});
8 unmodified lines
420 * @api public421 */422423app.all = function(path){423 this.lazyrouter();424425 var route = this._router.route(path);424 var route = this._baseRoute(path);425 var args = [].slice.call(arguments, 1);426 methods.forEach(function(method){427 route[method].apply(route, args);428 });
100 unmodified lines
529app.listen = function(){530 var server = http.createServer(this);531 return server.listen.apply(server, arguments);532};533534/**535 * Get or create a new base route for path.536 *537 * @param {String} path538 * @return {Route}539 * @api private540 */541542app._baseRoute = function(path){543 this.lazyrouter();544545 var key = typeof path !== 'string'546 ? 'o:' + String(path)547 : 's:' + path;548549 if (path.ignoreCase || !this._router.caseSensitive) {550 key = 'i' + key.toLowerCase();551 }552553 var route = this._baseRoutes[key];554555 if (!route) {556 route = this._router.route(path);557 this._baseRoutes[key] = route;558 }559560 return route;561};
modified:test/app.head.js+22 added-1 removed
modified:History.md+1 added
1unreleased2==========34 * fix behavior of multiple `app.VERB` for the same path5 * update type-is to 1.2.06 - support suffix matching784.2.0 / 2014-05-11
1411 unmodified lines