Permalink
Browse files

tests for issues 1115 fix for utils

  • Loading branch information...
1 parent 73bed61 commit 3827f5ef8b551f9525ddc951614ddc1c18a9a415 @riadhchtara riadhchtara committed with tj Jul 3, 2012
Showing with 24 additions and 1 deletion.
  1. +1 −1 lib/utils.js
  2. +23 −0 test/app.router.js
View
@@ -273,7 +273,7 @@ exports.pathRegexp = function(path, keys, sensitive, strict) {
+ (optional ? slash : '')
+ (format || '') + (capture || (format && '([^/.]+?)' || '([^/]+?)')) + ')'
+ (optional || '')
- + (star ? '(/*)' : '');
+ + (star ? '(/*)?' : '');
})
.replace(/([\/.])/g, '\\$1')
.replace(/\*/g, '(.*)');
View
@@ -347,6 +347,29 @@ describe('app.router', function(){
.expect('users/0.json', done);
})
+ it('should not be greedy immediately after param', function(done){
+ var app = express();
+
+ app.get('/user/:user*', function(req, res){
+ res.end(req.params.user);
+ });
+
+ request(app)
+ .get('/user/122')
+ .expect('122', done);
+ })
+ it('should eat everything after /', function(done){
+ var app = express();
+
+ app.get('/user/:user*', function(req, res){
+ res.end(req.params.user);
+ });
+
+ request(app)
+ .get('/user/122/aaa')
+ .expect('122', done);
+ })
+
it('should span multiple segments', function(done){
var app = express();

0 comments on commit 3827f5e

Please sign in to comment.