Fixed issues introduced by the node url module changes. Closes 126.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Everything is good to go now! should run fine. all specs pass.
authored by visionmedia · committed by visionmedia · parent 25b3426 · Browse files · 8 files·+13 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+13 added−12 removed
- tests:+3 added−3 removed
- other:+10 added−9 removed
Provenance
- Commit
a1eba23- Tree
8b8cd17- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
25b3426
8 files changed+13 added−12 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.url.path || '/' path = request.url.pathname || '/' return '<html> \n\ <head> \n\ <title>Express -- Not Found</title> \n\ ' + style + ' \n\16 unmodified linesmodified: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.url.path || '/') + '"' + event.request.method.toUpperCase() + ' ' + (event.request.url.pathname || '/') + ' 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.url.path + ': ' + event.request.url.pathname + ': ' + (Number(new Date) - this.start) + ' ms') } }})No newline at end of fileNo newline at end of filemodified:lib/express/core.js+1 added-1 removed
145 unmodified lines146 */147 148 match: function(route) {149 if (this.request.method.toLowerCase() == route.method)150- if (this.request.captures = this.request.url.path.match(route.path)) {150+ if (this.request.captures = this.request.url.pathname.match(route.path)) {151 this.mapParams(route)152 return true153 }154 },124 unmodified linesmodified:lib/express/helpers.js+5 added-4 removed
133 unmodified lines134 return params135 }136 137 /**138- * Parse params _string_ into a nested hash.138+ * Parse params _str_ into a nested hash.139 *140- * @param {string} string140+ * @param {string} str141 * @return {hash}142 * @api public143 */144 145-exports.parseParams = function(string) {146- return exports.parseNestedParams($(string.split('&')).reduce({}, function(params, pair){145+exports.parseParams = function(str) {146+ if (typeof str !== 'string') return147+ return exports.parseNestedParams($(str.split('&')).reduce({}, function(params, pair){148 pair = pair.split('=')149 params[pair[0]] = pair[1]150 return params151 }))1 unmodified linemodified:lib/express/request.js+1 added-1 removed
21 unmodified lines22 23 InvalidResponseBody = ExpressError.extend({24 name: 'InvalidResponseBody',25 init: function(request) {26- this.message = request.method + ' ' + JSON.encode(request.url.path) + ' did not respond with a body string'26+ this.message = request.method + ' ' + JSON.encode(request.url.pathname) + ' did not respond with a body string'27 }28 })29 30 // --- Helpers233 unmodified linesmodified:spec/spec.plugins.method-override.js+2 added-2 removed
10 unmodified lines1112131415151617181920212222232425262710 unmodified lines it 'should consider _method as the HTTP method' put('/user', function(){ return 'updated user' }) post('/user', { url: { params: { _method: 'put' }}}).body.should.eql 'updated user' post('/user', { body: '_method=put', headers: { 'content-type': 'application/x-www-form-urlencoded' }}).body.should.eql 'updated user' end it 'should force _method to lowercase to conform to internal uses' put('/user', function(){ return 'updated user' }) post('/user', { url: { params: { _method: 'PUT' }}}).body.should.eql 'updated user' post('/user', { body: '_method=PUT', headers: { 'content-type': 'application/x-www-form-urlencoded' }}).body.should.eql 'updated user' end end end endendmodified:spec/spec.request.js+1 added-1 removed
156 unmodified lines157 it 'should access request.url.params'158 get('/user', function(){159 return this.param('page') || 'First page'160 })161- get('/user?page=2').body.should.eql 'First page'161+ get('/user').body.should.eql 'First page'162 get('/user?page=2').body.should.eql '2'163 end164 165 it 'should work with splats'8 unmodified lines