Compare commits

...

11 Commits
3.3.1 ... 2.4.4

Author SHA1 Message Date
Tj Holowaychuk
75361fb177 Release 2.4.4 2011-08-05 04:29:52 -07:00
Tj Holowaychuk
21f9b386db empty string 2011-08-05 04:28:31 -07:00
Tj Holowaychuk
271cb16ecd Fixed res.send(204) (again?) 2011-08-05 04:28:08 -07:00
Tj Holowaychuk
803ec213d7 Fixed res.header() intention of a set, even when undefined 2011-08-03 19:59:40 -07:00
Tj Holowaychuk
9e9042f1eb added header.jade to jade example 2011-08-02 08:59:14 -07:00
Tj Holowaychuk
ec4c86f46d fixed * consumption 2011-07-29 09:51:09 -07:00
Arpad Borsos
45f22ec602 specialcase .:format routing to not include a dot in the capture group 2011-07-29 09:43:34 -07:00
Tj Holowaychuk
0e1eb72058 fixed a jade test 2011-07-29 09:32:36 -07:00
Tj Holowaychuk
4690b6cdf2 tweak generated stylus 2011-07-25 11:15:10 -07:00
Tj Holowaychuk
22204a5ce1 Fixed res.send(204) support. Closes #771 2011-07-22 08:34:13 -07:00
Tj Holowaychuk
1ec16c0450 qs >= 0.3.0 2011-07-19 12:08:50 -07:00
11 changed files with 86 additions and 25 deletions

View File

@@ -1,4 +1,11 @@
2.4.4 / 2011-08-05
==================
* Fixed `res.header()` intention of a set, even when `undefined`
* Fixed `*`, value no longer required
* Fixed `res.send(204)` support. Closes #771
2.4.3 / 2011-07-14
==================

View File

@@ -143,10 +143,10 @@ var sass = [
var stylus = [
'body'
, ' padding 50px'
, ' font 14px "Lucida Grande", Helvetica, Arial, sans-serif'
, ' padding: 50px'
, ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif'
, 'a'
, ' color #00B7FF'
, ' color: #00B7FF'
].join('\n');
/**

View File

@@ -0,0 +1,3 @@
head
title Jade Example
link(rel="stylesheet", href="/stylesheets/style.css")

View File

@@ -1,6 +1,4 @@
!!!
html
head
title Jade Example
link(rel="stylesheet", href="/stylesheets/style.css")
include header
body!= body

View File

@@ -28,7 +28,7 @@ var exports = module.exports = connect.middleware;
* Framework version.
*/
exports.version = '2.4.3';
exports.version = '2.4.4';
/**
* Shortcut for `new Server(...)`.

View File

@@ -52,7 +52,7 @@ res.send = function(body, headers, status){
status = status || this.statusCode;
// allow 0 args as 204
if (!arguments.length || undefined === body) body = status = 204;
if (!arguments.length || undefined === body) status = 204;
// determine content type
switch (typeof body) {
@@ -81,7 +81,7 @@ res.send = function(body, headers, status){
}
// populate Content-Length
if (!this.header('Content-Length')) {
if (undefined !== body && !this.header('Content-Length')) {
this.header('Content-Length', Buffer.isBuffer(body)
? body.length
: Buffer.byteLength(body));
@@ -100,6 +100,7 @@ res.send = function(body, headers, status){
if (204 == status || 304 == status) {
this.removeHeader('Content-Type');
this.removeHeader('Content-Length');
body = '';
}
// respond
@@ -270,17 +271,14 @@ res.download = function(path, filename, fn, fn2){
*
* @param {String} name
* @param {String} val
* @return {String}
* @return {ServerResponse} for chaining
* @api public
*/
res.header = function(name, val){
if (val === undefined) {
return this.getHeader(name);
} else {
this.setHeader(name, val);
return val;
}
if (1 == arguments.length) return this.getHeader(name);
this.setHeader(name, val);
return this;
};
/**

View File

@@ -81,10 +81,10 @@ function normalize(path, keys, sensitive, strict) {
+ (optional ? '' : slash)
+ '(?:'
+ (optional ? slash : '')
+ (format || '') + (capture || '([^/]+?)') + ')'
+ (format || '') + (capture || (format && '([^/.]+?)' || '([^/]+?)')) + ')'
+ (optional || '');
})
.replace(/([\/.])/g, '\\$1')
.replace(/\*/g, '(.+)');
.replace(/\*/g, '(.*)');
return new RegExp('^' + path + '$', sensitive ? '' : 'i');
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "express",
"description": "Sinatra inspired web development framework",
"version": "2.4.3",
"version": "2.4.4",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"contributors": [
{ "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" },
@@ -12,7 +12,7 @@
"dependencies": {
"connect": ">= 1.5.2 < 2.0.0",
"mime": ">= 0.0.1",
"qs": ">= 0.0.6"
"qs": ">= 0.3.0"
},
"devDependencies": {
"connect-form": "0.2.1",

View File

@@ -3,4 +3,4 @@
- else if (lastInCollection)
li.last= word
- else
li(class: 'word-' + indexInCollection)= word
li(class='word-' + indexInCollection)= word

View File

@@ -68,8 +68,8 @@ module.exports = {
});
app.get('/json', function(req, res){
res.header('X-Foo', 'bar');
res.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);
res.header('X-Foo', 'bar')
.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);
});
app.get('/text', function(req, res){
@@ -97,7 +97,11 @@ module.exports = {
app.get('/noargs', function(req, res, next){
res.send();
});
app.get('/no-content', function(req, res, next){
res.send(204);
});
app.get('/undefined', function(req, res, next){
res.send(undefined);
});
@@ -162,6 +166,13 @@ module.exports = {
'Content-Type': 'application/octet-stream'
, 'Content-Length': '6'
}});
assert.response(app,
{ url: '/no-content' },
{ status: 204 }, function(res){
assert.equal(undefined, res.headers['content-type']);
assert.equal(undefined, res.headers['content-length']);
});
assert.response(app,
{ url: '/noargs' },

View File

@@ -138,6 +138,50 @@ module.exports = {
{ body: 'Cannot GET /user/ab' });
},
'test named capture group after dot': function(){
var app = express.createServer();
app.get('/user/:name.:format?', function(req, res){
res.send(req.params.name + ' - ' + (req.params.format || ''));
});
assert.response(app,
{ url: '/user/foo' },
{ body: 'foo - ' });
assert.response(app,
{ url: '/user/foo.json' },
{ body: 'foo - json' });
assert.response(app,
{ url: '/user/foo.bar.json' },
{ body: 'foo.bar - json' });
},
'test optional * value': function(){
var app = express.createServer();
app.get('/admin*', function(req, res){
res.send(req.params[0]);
});
app.get('/file/*.*', function(req, res){
res.send(req.params[0] + ' - ' + req.params[1]);
});
assert.response(app,
{ url: '/file/some.foo.bar' },
{ body: 'some.foo - bar' });
assert.response(app,
{ url: '/admin', },
{ body: '', status: 200 });
assert.response(app,
{ url: '/adminify', },
{ body: 'ify', status: 200 });
},
'test app.param()': function(){
var app = express.createServer();