Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests for issues 1115 fix for utils

  • Loading branch information...
commit 3827f5ef8b551f9525ddc951614ddc1c18a9a415 1 parent 73bed61
@riadhchtara riadhchtara authored tj committed
Showing with 24 additions and 1 deletion.
  1. +1 −1  lib/utils.js
  2. +23 −0 test/app.router.js
View
2  lib/utils.js
@@ -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
23 test/app.router.js
@@ -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();
Please sign in to comment.
Something went wrong with that request. Please try again.