mirror of
https://github.com/expressjs/express.git
synced 2026-02-26 08:45:36 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75361fb177 | ||
|
|
21f9b386db | ||
|
|
271cb16ecd | ||
|
|
803ec213d7 | ||
|
|
9e9042f1eb | ||
|
|
ec4c86f46d | ||
|
|
45f22ec602 | ||
|
|
0e1eb72058 | ||
|
|
4690b6cdf2 | ||
|
|
22204a5ce1 | ||
|
|
1ec16c0450 |
@@ -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
|
||||
==================
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
/**
|
||||
|
||||
3
examples/jade/views/header.jade
Normal file
3
examples/jade/views/header.jade
Normal file
@@ -0,0 +1,3 @@
|
||||
head
|
||||
title Jade Example
|
||||
link(rel="stylesheet", href="/stylesheets/style.css")
|
||||
@@ -1,6 +1,4 @@
|
||||
!!!
|
||||
html
|
||||
head
|
||||
title Jade Example
|
||||
link(rel="stylesheet", href="/stylesheets/style.css")
|
||||
include header
|
||||
body!= body
|
||||
@@ -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(...)`.
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
2
test/fixtures/magic.jade
vendored
2
test/fixtures/magic.jade
vendored
@@ -3,4 +3,4 @@
|
||||
- else if (lastInCollection)
|
||||
li.last= word
|
||||
- else
|
||||
li(class: 'word-' + indexInCollection)= word
|
||||
li(class='word-' + indexInCollection)= word
|
||||
@@ -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' },
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user