Socket
Socket
Sign inDemoInstall

express

Package Overview
Dependencies
Maintainers
1
Versions
279
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express - npm Package Compare versions

Comparing version 3.0.6 to 3.1.0

11

History.md
3.1.0 / 2013-01-25
==================
* add support for leading "." in "view engine" setting
* add array support to `res.set()`
* add node 0.8.x to travis.yml
* add "subdomain offset" setting for tweaking `req.subdomains`
* add `res.location(url)` implementing `res.redirect()`-like setting of Location
* use app.get() for x-powered-by setting for inheritance
* fix colons in passwords for `req.auth`
3.0.6 / 2013-01-04

@@ -3,0 +14,0 @@ ==================

3

lib/application.js

@@ -51,2 +51,3 @@ /**

this.set('env', process.env.NODE_ENV || 'development');
this.set('subdomain offset', 2);
debug('booting in %s mode', this.get('env'));

@@ -164,3 +165,3 @@

* engines to follow this convention, thus allowing them to
* work seemlessly within Express.
* work seeessly within Express.
*

@@ -167,0 +168,0 @@ * @param {String} ext

@@ -23,3 +23,3 @@ /**

exports.version = '3.0.5';
exports.version = '3.1.0';

@@ -26,0 +26,0 @@ /**

@@ -21,3 +21,3 @@

req.app = res.app = app;
if (app.settings['x-powered-by']) res.setHeader('X-Powered-By', 'Express');
if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
req.res = res;

@@ -24,0 +24,0 @@ res.req = req;

@@ -32,6 +32,6 @@

* // => "text/plain"
*
*
* req.get('content-type');
* // => "text/plain"
*
*
* req.get('Something');

@@ -43,7 +43,7 @@ * // => undefined

* @param {String} name
* @return {String}
* @return {String}
* @api public
*/
req.get =
req.get =
req.header = function(name){

@@ -72,3 +72,3 @@ switch (name = name.toLowerCase()) {

* Examples:
*
*
* // Accept: text/html

@@ -267,3 +267,3 @@ * req.accepts('html');

/**
* Check if the incoming request contains the "Content-Type"
* Check if the incoming request contains the "Content-Type"
* header field, and it contains the give mime `type`.

@@ -278,3 +278,3 @@ *

* // => true
*
*
* // When Content-Type is application/json

@@ -285,6 +285,6 @@ * req.is('json');

* // => true
*
*
* req.is('html');
* // => false
*
*
* @param {String} type

@@ -312,3 +312,3 @@ * @return {Boolean}

* Return the protocol string "http" or "https"
* when requested with TLS. When the "trust proxy"
* when requested with TLS. When the "trust proxy"
* setting is enabled the "X-Forwarded-Proto" header

@@ -403,4 +403,5 @@ * field will be trusted. If you're running behind

// credentials
auth = new Buffer(auth, 'base64').toString().split(':');
return { username: auth[0], password: auth[1] };
auth = new Buffer(auth, 'base64').toString().match(/^([^:]*):(.*)$/);
if (!auth) return;
return { username: auth[1], password: auth[2] };
});

@@ -411,5 +412,10 @@

*
* For example "tobi.ferrets.example.com"
* would provide `["ferrets", "tobi"]`.
* Subdomains are the dot-separated parts of the host before the main domain of
* the app. By default, the domain of the app is assumed to be the last two
* parts of the host. This can be changed by setting "subdomain offset".
*
* For example, if the domain is "tobi.ferrets.example.com":
* If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.
* If "subdomain offset" is 3, req.subdomains is `["tobi"]`.
*
* @return {Array}

@@ -420,6 +426,7 @@ * @api public

req.__defineGetter__('subdomains', function(){
var offset = this.app.get('subdomain offset');
return this.get('Host')
.split('.')
.slice(0, -2)
.reverse();
.reverse()
.slice(offset);
});

@@ -426,0 +433,0 @@

@@ -190,3 +190,3 @@ /**

this.get('Content-Type') || this.set('Content-Type', 'application/json');
return this.send(body);

@@ -235,3 +235,3 @@ };

this.set('Content-Type', 'application/json');
// jsonp

@@ -249,3 +249,3 @@ if (callback) {

* Transfer the file at the given `path`.
*
*
* Automatically sets the _Content-Type_ response header field.

@@ -272,3 +272,3 @@ * The callback `fn(err)` is invoked when the transfer is complete

* , file = req.params.file;
*
*
* req.user.mayViewFilesFrom(uid, function(yes){

@@ -418,7 +418,7 @@ * if (yes) {

* },
*
*
* 'text/html': function(){
* res.send('<p>hey</p>');
* },
*
*
* 'appliation/json': function(){

@@ -436,7 +436,7 @@ * res.send({ message: 'hey' });

* },
*
*
* html: function(){
* res.send('<p>hey</p>');
* },
*
*
* json: function(){

@@ -507,8 +507,9 @@ * res.send({ message: 'hey' });

*
* res.set('Foo', ['bar', 'baz']);
* res.set('Accept', 'application/json');
* res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
*
* Aliased as `res.header()`.
* Aliased as `res.header()`.
*
* @param {String|Object} field
* @param {String|Object|Array} field
* @param {String} val

@@ -519,9 +520,11 @@ * @return {ServerResponse} for chaining

res.set =
res.set =
res.header = function(field, val){
if (2 == arguments.length) {
this.setHeader(field, '' + val);
if (Array.isArray(val)) val = val.map(String);
else val = String(val);
this.setHeader(field, val);
} else {
for (var key in field) {
this.setHeader(key, '' + field[key]);
this.set(key, field[key]);
}

@@ -599,5 +602,5 @@ }

/**
* Redirect to the given `url` with optional response `status`
* defaulting to 302.
* Set the location header to `url`.
*

@@ -610,43 +613,27 @@ * The given `url` can also be the name of a mapped url, for

*
* res.redirect('/foo/bar');
* res.redirect('http://example.com');
* res.redirect(301, 'http://example.com');
* res.redirect('http://example.com', 301);
* res.redirect('../login'); // /blog/post/1 -> /blog/login
* res.location('/foo/bar').;
* res.location('http://example.com');
* res.location('../login'); // /blog/post/1 -> /blog/login
*
* Mounting:
*
* When an application is mounted, and `res.redirect()`
* is given a path that does _not_ lead with "/". For
* example suppose a "blog" app is mounted at "/blog",
* the following redirect would result in "/blog/login":
* When an application is mounted and `res.location()`
* is given a path that does _not_ lead with "/" it becomes
* relative to the mount-point. For example if the application
* is mounted at "/blog", the following would become "/blog/login".
*
* res.redirect('login');
* res.location('login');
*
* While the leading slash would result in a redirect to "/login":
* While the leading slash would result in a location of "/login":
*
* res.redirect('/login');
* res.location('/login');
*
* @param {String} url
* @param {Number} code
* @api public
*/
res.redirect = function(url){
res.location = function(url){
var app = this.app
, req = this.req
, head = 'HEAD' == req.method
, status = 302
, body;
, req = this.req;
// allow status / url
if (2 == arguments.length) {
if ('number' == typeof url) {
status = url;
url = arguments[1];
} else {
status = arguments[1];
}
}
// setup redirect map

@@ -671,2 +658,48 @@ var map = { back: req.get('Referrer') || '/' };

// Respond
this.set('Location', url);
return this;
};
/**
* Redirect to the given `url` with optional response `status`
* defaulting to 302.
*
* The resulting `url` is determined by `res.location()`, so
* it will play nicely with mounted apps, relative paths,
* `"back"` etc.
*
* Examples:
*
* res.redirect('/foo/bar');
* res.redirect('http://example.com');
* res.redirect(301, 'http://example.com');
* res.redirect('http://example.com', 301);
* res.redirect('../login'); // /blog/post/1 -> /blog/login
*
* @param {String} url
* @param {Number} code
* @api public
*/
res.redirect = function(url){
var app = this.app
, head = 'HEAD' == this.req.method
, status = 302
, body;
// allow status / url
if (2 == arguments.length) {
if ('number' == typeof url) {
status = url;
url = arguments[1];
} else {
status = arguments[1];
}
}
// Set location header
this.location(url);
url = this.get('Location');
// Support text/{plain,html} by default

@@ -690,3 +723,2 @@ this.format({

this.statusCode = status;
this.set('Location', url);
this.set('Content-Length', Buffer.byteLength(body));

@@ -693,0 +725,0 @@ this.end(head ? null : body);

@@ -41,3 +41,3 @@ /**

var ext = this.ext = extname(name);
if (!ext) name += (ext = this.ext = '.' + this.defaultEngine);
if (!ext) name += (ext = this.ext = ('.' != this.defaultEngine[0] ? '.' : '') + this.defaultEngine);
this.engine = engines[ext] || (engines[ext] = require(ext.slice(1)).__express);

@@ -44,0 +44,0 @@ this.path = this.lookup(name);

{
"name": "express",
"description": "Sinatra inspired web development framework",
"version": "3.0.6",
"version": "3.1.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -9,5 +9,4 @@

app.get('/:type/size::size', ['test'], function(req, res){
console.log(req.params.type);
console.log(req.params.size);
app.get('/', function(req, res){
console.log(req.query);
});

@@ -14,0 +13,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc