Skip to content

Commit

Permalink
Fixed issues introduced by the node url module changes. Closes 126.
Browse files Browse the repository at this point in the history
Everything is good to go now! should run fine. all specs pass.
  • Loading branch information
tj committed Jan 6, 2010
1 parent 25b3426 commit a1eba23
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/express/core.js
Expand Up @@ -147,7 +147,7 @@ Router = Class({

match: function(route) {
if (this.request.method.toLowerCase() == route.method)
if (this.request.captures = this.request.url.path.match(route.path)) {
if (this.request.captures = this.request.url.pathname.match(route.path)) {
this.mapParams(route)
return true
}
Expand Down
9 changes: 5 additions & 4 deletions lib/express/helpers.js
Expand Up @@ -135,15 +135,16 @@ exports.parseNestedParams = function(params) {
}

/**
* Parse params _string_ into a nested hash.
* Parse params _str_ into a nested hash.
*
* @param {string} string
* @param {string} str
* @return {hash}
* @api public
*/

exports.parseParams = function(string) {
return exports.parseNestedParams($(string.split('&')).reduce({}, function(params, pair){
exports.parseParams = function(str) {
if (typeof str !== 'string') return
return exports.parseNestedParams($(str.split('&')).reduce({}, function(params, pair){
pair = pair.split('=')
params[pair[0]] = pair[1]
return params
Expand Down
2 changes: 1 addition & 1 deletion lib/express/pages/not-found.js
Expand Up @@ -6,7 +6,7 @@ var style = require('express/pages/style').style
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\
Expand Down
2 changes: 1 addition & 1 deletion lib/express/plugins/common-logger.js
Expand Up @@ -41,7 +41,7 @@ exports.CommonLogger = Plugin.extend({
'-',
'-',
'[' + 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(' '))
Expand Down
2 changes: 1 addition & 1 deletion lib/express/plugins/profiler.js
Expand Up @@ -18,7 +18,7 @@ exports.Profiler = Plugin.extend({

response: function(event) {
puts(event.request.method + ' ' +
event.request.url.path + ': ' +
event.request.url.pathname + ': ' +
(Number(new Date) - this.start) + ' ms')
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/express/request.js
Expand Up @@ -23,7 +23,7 @@ InvalidStatusCode = ExpressError.extend({
InvalidResponseBody = ExpressError.extend({
name: 'InvalidResponseBody',
init: function(request) {
this.message = request.method + ' ' + JSON.encode(request.url.path) + ' did not respond with a body string'
this.message = request.method + ' ' + JSON.encode(request.url.pathname) + ' did not respond with a body string'
}
})

Expand Down
4 changes: 2 additions & 2 deletions spec/spec.plugins.method-override.js
Expand Up @@ -12,14 +12,14 @@ describe 'Express'
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
Expand Down
2 changes: 1 addition & 1 deletion spec/spec.request.js
Expand Up @@ -158,7 +158,7 @@ describe 'Express'
get('/user', function(){
return this.param('page') || 'First page'
})
get('/user?page=2').body.should.eql 'First page'
get('/user').body.should.eql 'First page'
get('/user?page=2').body.should.eql '2'
end

Expand Down

0 comments on commit a1eba23

Please sign in to comment.