Permalink
Browse files

refactoring

  • Loading branch information...
1 parent 44ed697 commit cc99e4470c23dceb9a9add8a2f87a17d4007bf20 @tj tj committed May 24, 2011
Showing with 3 additions and 6 deletions.
  1. +3 −6 lib/express-params.js
View
9 lib/express-params.js
@@ -33,10 +33,8 @@ exports.extend = function(app){
exports.extend.regexp = function(app){
app.param(function(name, fn){
if (fn instanceof RegExp) {
- return function(req, res, next){
- var val = req.params[name]
- , captures;
-
+ return function(req, res, next, val){
+ var captures;
if (captures = fn.exec(String(val))) {
req.params[name] = captures;
next();
@@ -60,8 +58,7 @@ exports.extend.regexp = function(app){
exports.extend.returnValue = function(app){
app.param(function(name, fn){
if (fn.length < 3) {
- return function(req, res, next){
- var val = req.params[name];
+ return function(req, res, next, val){
val = req.params[name] = fn(val);
if (exports.invalidParamReturnValue(val)) {
next('route');

0 comments on commit cc99e44

Please sign in to comment.