Merge branch 'master' of github.com:visionmedia/express
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents f8a9cbe, 15f2e0c · Browse files · 5 files·+33 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+33 added−8 removed
- tests:+18 added−1 removed
- other:+15 added−7 removed
Provenance
- Commit
3360613- Tree
28d3830- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent 1
f8a9cbe- Parent 2
15f2e0c
5 files changed+33 added−8 removed
modified:lib/router/index.js+5 added
9 unmodified lines10 11 var Route = require('./route')12 , Collection = require('./collection')13 , utils = require('../utils')14+ , debug = require('debug')('express:routes')15 , parse = require('url').parse;16 17 /**18 * Expose `Router` constructor.181 unmodified lines200 Router.prototype._dispatch = function(req, res, next){201 var params = this.params202 , self = this;203 204+ debug('dispatching %s %s', req.method, req.url);205+206 // route dispatch207 (function pass(i, err){208 var paramCallbacks209 , paramIndex = 015 unmodified lines225 if (!route && 'OPTIONS' == req.method) return self._options(req, res);226 227 // no route228 if (!route) return next(err);229+ debug('matched %s %s', route.method, route.path);230 231 // we have a route232 // start at param 0233 req.params = route.params;173 unmodified lines407 // ensure path was given408 if (!path) throw new Error('Router#' + method + '() requires a path');409 410 // create the route411+ debug('defined %s %s', method, path);412 var route = new Route(method, path, callbacks, {413 sensitive: this.caseSensitive414 , strict: this.strict415 });6 unmodified linesmodified:lib/router/route.js+3 added-2 removed
1123452 unmodified lines57585960626162636465666768697071727374757613 unmodified lines
/*! * Express - router - Route * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca> * MIT Licensed52 unmodified lines * which will contain the placeholder * key names. For example "/user/:id" will * then contain ["id"]. * * @param {String|RegExp} path * @param {String|RegExp|Array} path * @param {Array} keys * @param {Boolean} sensitive * @param {Boolean} strict * @return {RegExp} * @api private */
function normalize(path, keys, sensitive, strict) { if (path instanceof RegExp) return path; if (path instanceof Array) path = '(' + path.join('|') + ')'; path = path .concat(strict ? '' : '/?') .replace(/\/\(/g, '(?:/') .replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g, function(_, slash, format, key, capture, optional){13 unmodified linesmodified:lib/application.js+4 added-2 removed
10 unmodified lines11 var connect = require('connect')12 , Router = require('./router')13 , methods = Router.methods.concat('del', 'all')14 , middleware = require('./middleware')15+ , debug = require('debug')('express:application')16 , View = require('./view')17 , url = require('url')18 , utils = connect.utils19 , path = require('path')20 , http = require('http')21 , join = path.join21- , fs = require('fs')22- , qs = require('qs');22+ , fs = require('fs');23 24 /**25 * Application prototype.26 */44 unmodified lines71 var self = this;72 73 // default settings74 this.set('env', process.env.NODE_ENV || 'development');75+ debug('booting in %s mode', this.get('env'));76 77 // implicit middleware78 this.use(connect.query());79 this.use(middleware.init(this));95 unmodified lines175 });176 };177 }178 179+ debug('use %s %s', route, fn.name || 'unnamed');180 connect.proto.use.call(this, route, fn);181 182 // mounted an app183 if (app) {348 unmodified linesmodified:test/app.router.js+18 added-1 removed
1-1 var express = require('../')2 , request = require('./support/http')3 , assert = require('assert');4 103 unmodified lines108 .get('/user/10/edit')109 .expect('editing user 10', done);110 })111 })112+ 113+ describe('when given an array', function(){114+ it('should match all paths in the array', function(done){115+ var app = express();116+ 117+ app.get(['/one', '/two'], function(req, res){118+ res.end('works');119+ });120+ 121+ request(app)122+ .get('/one')123+ .expect('works', function() {124+ request(app)125+ .get('/two')126+ .expect('works', done);127+ });128+ })129+ })130 131 describe('case sensitivity', function(){132 it('should be disabled by default', function(done){133 var app = express();393 unmodified linesmodified:package.json+3 added-3 removed
10 unmodified lines111213141516171516171819202116 unmodified lines10 unmodified lines ], "dependencies": { "connect": "git://github.com/senchalabs/connect.git", "commander": "0.5.1", "mime": ">= 1.2.4", "qs": ">= 0.4.0", "mkdirp": "0.2.2" "mime": "1.2.4", "mkdirp": "0.3.0", "debug": "*" }, "devDependencies": { "ejs": "*", "mocha": "*",16 unmodified lines