Fixing uri -> url
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 9d09637 · Browse files · 10 files·+26 added−27 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+26 added−27 removed
- tests:+6 added−12 removed
- other:+20 added−15 removed
Provenance
- Commit
30d23a8- Tree
07b6f18- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
9d09637
10 files changed+26 added−27 removed
modified:lib/express/pages/not-found.js+1 added-1 removed
4 unmodified lines5678991011121316 unmodified lines4 unmodified lines
exports.render = function(request) { request.contentType('html') var method = request.method.toLowerCase(), path = request.uri.path || '/' path = request.url.path || '/' return '<html> \n\ <head> \n\ <title>Express -- Not Found</title> \n\ ' + style + ' \n\16 unmodified linesmodified:lib/express/pages/show-exceptions.js+2 added-2 removed
64 unmodified lines6566676869697071727373747576777864 unmodified lines ' + hash(request.params) + ' \n\ </table> \n\ <h3>GET</h3> \n\ <table id="get-params"> \n\ ' + hash(request.uri.params) + ' \n\ ' + hash(request.url.params) + ' \n\ </table> \n\ <h3>POST</h3> \n\ <table id="post-params"> \n\ ' + hash(request.uri.post) + ' \n\ ' + hash(request.url.post) + ' \n\ </table> \n\ </div> \n\ </body> \n\ </html>'}modified:lib/express/plugins/common-logger.js+1 added-1 removed
39 unmodified lines404142434444454647482 unmodified lines39 unmodified lines puts([event.request.headers.host, '-', '-', '[' + format(new Date) + ']', '"' + event.request.method.toUpperCase() + ' ' + (event.request.uri.path || '/') + '"' + event.request.method.toUpperCase() + ' ' + (event.request.url.path || '/') + ' HTTP/' + event.request.httpVersion + '"', event.request.response.status, event.request.response.headers['content-length'] || 0].join(' ')) }2 unmodified linesmodified:lib/express/plugins/profiler.js+1 added-1 removed
16 unmodified lines1718192021212223242516 unmodified lines */ response: function(event) { puts(event.request.method + ' ' + event.request.uri.path + ': ' + event.request.url.path + ': ' + (Number(new Date) - this.start) + ' ms') } }})No newline at end of fileNo newline at end of filemodified:lib/express/plugins/redirect.js+5 added-5 removed
10 unmodified lines11 init: function() {12 Request.include({13 14 /**15- * Redirect to _uri_ with optional status _code_,15+ * Redirect to _url_ with optional status _code_,16 * defaulting to 303 "See Other".17 *18 * When using redirect('home') the resolution19 * is as follows:5 unmodified lines25 * When using redirect('back') the HTTP referrer26 * header is used. Commonly misspelled as 'referer'27 * which is supported as well.28 *29- * @param {string} uri29+ * @param {string} url30 * @settings 'home', 'basepath'31 * @api public32 */33 34- redirect: function(uri, code) {35- if (uri == 'back' || uri == 'home') uri = this[uri]36- this.header('location', uri)34+ redirect: function(url, code) {35+ if (url == 'back' || url == 'home') url = this[url]36+ this.header('location', url)37 this.halt(code || 303)38 } 39 })40 }17 unmodified linesmodified:lib/express/spec/mocks.js+1 added-7 removed
20 unmodified lines21 */22 23 init: function(method, path, options) {24 this.method = method25+ this.url = path26 this.connection = {27 remoteAddress: '127.0.0.1'28 }28- this.uri = {29- queryString: '',30- fragment: '',31- params: {},32- path: path,33- full: path34- }29 this.headers = {30 'host': 'localhost',31 'user-agent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19',32 'accept': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',97 unmodified linesmodified:lib/express/core.js+7 added-2 removed
9 unmodified lines10 process.mixin(require('express/plugin'))11 process.mixin(require('express/mime'))12 process.mixin(require('express/dsl'))13 14+var url = require('url')15+16 // --- Route17 18 Route = Class({19 76 unmodified lines96 97 Router = Class({98 99 /**98- * Initialize with _request_.100+ * Initialize with _request_ and parse url.101 *102 * @param {Request} request103 * @api private104 */105 106 init: function(request) {107 this.request = request108+ p('test')109+ p(this.request.url)110+ p(url.parse(this.request.url))111 },112 113 /**114 * Evaluate the matched route against #request.36 unmodified lines151 */152 153 match: function(route) {154 if (this.request.method.toLowerCase() == route.method)150- if (this.request.captures = this.request.uri.path.match(route.path)) {155+ if (this.request.captures = this.request.url.path.match(route.path)) {156 this.mapParams(route)157 return true158 }159 },124 unmodified linesmodified:lib/express/request.js+3 added-3 removed
25 unmodified lines26 27 InvalidResponseBody = ExpressError.extend({28 name: 'InvalidResponseBody',29 init: function(request) {30- this.message = request.method + ' ' + JSON.encode(request.uri.path) + ' did not respond with a body string'30+ this.message = request.method + ' ' + JSON.encode(request.url.path) + ' did not respond with a body string'31 }32 })33 34 // --- Helpers26 unmodified lines61 init: function(request, response) {62 process.mixin(true, this, request)63 response.headers = {}64 this.response = response65- this.uri.path = exports.normalizePath(this.uri.path)65+ this.url.path = exports.normalizePath(this.url.path)66 this.params = { 67- get: parseNestedParams(this.uri.params), 67+ get: parseNestedParams(this.url.params), 68 post: {}, 69 path: {}70 }71 this.plugins = $(Express.plugins).map(function(plugin){189 unmodified linesmodified:spec/spec.plugins.method-override.js+2 added-2 removed
10 unmodified lines11 it 'should consider _method as the HTTP method'12 put('/user', function(){13 return 'updated user'14 })15- post('/user', { uri: { params: { _method: 'put' }}}).body.should.eql 'updated user'15+ post('/user', { url: { params: { _method: 'put' }}}).body.should.eql 'updated user'16 end17 18 it 'should force _method to lowercase to conform to internal uses'19 put('/user', function(){20 return 'updated user'21 })22- post('/user', { uri: { params: { _method: 'PUT' }}}).body.should.eql 'updated user'22+ post('/user', { url: { params: { _method: 'PUT' }}}).body.should.eql 'updated user'23 end24 end25 end26 end1 unmodified linemodified:spec/spec.request.js+3 added-3 removed
152 unmodified lines153 get('/user/12').body.should.eql '12'154 get('/product/ipod').body.should.eql 'ipod'155 end156 157- it 'should access request.uri.params'157+ it 'should access request.url.params'158 get('/user', function(){159 return this.param('page') || 'First page'160 })161- get('/user').body.should.eql 'First page'162- get('/user', { uri: { params: { page: '2' }}}).body.should.eql '2'161+ get('/user?page=2').body.should.eql 'First page'162+ get('/user?page=2').body.should.eql '2'163 end164 165 it 'should work with splats'166 get('/:path/*.*', function(path, file, ext){7 unmodified lines