Skip to content
Myr

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

10 files+26 added−27 removed

modified:lib/express/pages/not-found.js+1 added-1 removed
modified:lib/express/pages/show-exceptions.js+2 added-2 removed
modified:lib/express/plugins/common-logger.js+1 added-1 removed
modified:lib/express/plugins/profiler.js+1 added-1 removed
modified:lib/express/plugins/redirect.js+5 added-5 removed
10 unmodified lines
11 init: function() {12 Request.include({1314 /**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 lines
25 * 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 */3334 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 lines
modified:lib/express/spec/mocks.js+1 added-7 removed
20 unmodified lines
21 */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 lines
modified:lib/express/core.js+7 added-2 removed
9 unmodified lines
10process.mixin(require('express/plugin'))11process.mixin(require('express/mime'))12process.mixin(require('express/dsl'))1314var url = require('url')1516// --- Route1718Route = Class({19
76 unmodified lines
9697Router = 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 lines
151 */152153 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 lines
modified:lib/express/request.js+3 added-3 removed
25 unmodified lines
2627InvalidResponseBody = 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})3334// --- Helpers
26 unmodified lines
61 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 lines
modified:spec/spec.plugins.method-override.js+2 added-2 removed
10 unmodified lines
11 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 end
1 unmodified line
modified:spec/spec.request.js+3 added-3 removed
152 unmodified lines
153 get('/user/12').body.should.eql '12'154 get('/product/ipod').body.should.eql 'ipod'155 end156157 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 end164165 it 'should work with splats'166 get('/:path/*.*', function(path, file, ext){
7 unmodified lines