Skip to content
Myr

Revert "Added + support to the router"

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

This reverts commit 6aaa7dc26dc12de5f91e5f747408f121fb39d2cc.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 3c0c961 · Browse files · 2 files+18 added−25 removed
This commit

State

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

Diff stats

2 files+18 added−25 removed

  • tests:+18 added−23 removed
  • other:+0 added−2 removed

2 files+18 added−25 removed

modified:lib/utils.js-2 removed
262 unmodified lines
263 if (Array.isArray(path)) path = '(' + path.join('|') + ')';264 path = path265 .concat(strict ? '' : '/?')266 .replace(/\/\(/g, '(?:/')267 .replace(/\+/g, '__plus__')267 .replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g, function(_, slash, format, key, capture, optional){268 keys.push({ name: key, optional: !! optional });269 slash = slash || '';270 return ''
3 unmodified lines
274 + (format || '') + (capture || (format && '([^/.]+?)' || '([^/]+?)')) + ')'275 + (optional || '');276 })277 .replace(/([\/.])/g, '\\$1')279 .replace(/__plus__/g, '(.+)')278 .replace(/\*/g, '(.*)');279 return new RegExp('^' + path + '$', sensitive ? '' : 'i');280}
modified:test/app.router.js+18 added-23 removed
254 unmodified lines
255 })256 })257 })258259 it('should allow escaped regexp', function(done){260 var app = express();261262 app.get('/user/\\d+', function(req, res){263 res.end('woot');264 });265266 request(app)267 .get('/user/10')268 .end(function(res){269 res.statusCode.should.equal(200);270 request(app)271 .get('/user/tj')272 .expect(404, done);273 });274 })275 276 it('should allow literal "."', function(done){277 var app = express();278279 app.get('/api/users/:from..:to', function(req, res){
7 unmodified lines
287 .get('/api/users/1..50')288 .expect('users from 1 to 50', done);289 })290274 describe('+', function(){291 describe('*', function(){292 it('should denote a greedy capture group', function(done){293 var app = express();294278 app.get('/blog+', function(req, res){279 res.end(req.params[0] || 'nothing');280 });281282 request(app)283 .get('/blog')284 .expect(404, function(){285 request(app)286 .get('/blog/post')287 .expect(200, function(){288 request(app)289 .get('/blog-admin')290 .expect(200, done)291 })292 });293 })294 })295296 describe('*', function(){297 it('should denote an optional greedy capture group', function(done){298 var app = express();299295 app.get('/user/*.json', function(req, res){296 res.end(req.params[0]);297 });298
274 unmodified lines