Permalink
Browse files

Revert "Added + support to the router"

This reverts commit 6aaa7dc.
  • Loading branch information...
1 parent 3c0c961 commit 140efb574c4d10e11f7a0fc83b6c51ec674165c3 @tj tj committed Jun 22, 2012
Showing with 18 additions and 25 deletions.
  1. +0 −2 lib/utils.js
  2. +18 −23 test/app.router.js
View
@@ -264,7 +264,6 @@ exports.pathRegexp = function(path, keys, sensitive, strict) {
path = path
.concat(strict ? '' : '/?')
.replace(/\/\(/g, '(?:/')
- .replace(/\+/g, '__plus__')
.replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g, function(_, slash, format, key, capture, optional){
keys.push({ name: key, optional: !! optional });
slash = slash || '';
@@ -276,7 +275,6 @@ exports.pathRegexp = function(path, keys, sensitive, strict) {
+ (optional || '');
})
.replace(/([\/.])/g, '\\$1')
- .replace(/__plus__/g, '(.+)')
.replace(/\*/g, '(.*)');
return new RegExp('^' + path + '$', sensitive ? '' : 'i');
}
View
@@ -256,6 +256,23 @@ describe('app.router', function(){
})
})
+ it('should allow escaped regexp', function(done){
+ var app = express();
+
+ app.get('/user/\\d+', function(req, res){
+ res.end('woot');
+ });
+
+ request(app)
+ .get('/user/10')
+ .end(function(res){
+ res.statusCode.should.equal(200);
+ request(app)
+ .get('/user/tj')
+ .expect(404, done);
+ });
+ })
+
it('should allow literal "."', function(done){
var app = express();
@@ -271,30 +288,8 @@ describe('app.router', function(){
.expect('users from 1 to 50', done);
})
- describe('+', function(){
- it('should denote a greedy capture group', function(done){
- var app = express();
-
- app.get('/blog+', function(req, res){
- res.end(req.params[0] || 'nothing');
- });
-
- request(app)
- .get('/blog')
- .expect(404, function(){
- request(app)
- .get('/blog/post')
- .expect(200, function(){
- request(app)
- .get('/blog-admin')
- .expect(200, done)
- })
- });
- })
- })
-
describe('*', function(){
- it('should denote an optional greedy capture group', function(done){
+ it('should denote a greedy capture group', function(done){
var app = express();
app.get('/user/*.json', function(req, res){

0 comments on commit 140efb5

Please sign in to comment.