Merge tag '3.12.0'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parents f498b66, 75422c1 · Browse files · 7 files·+64 added−88 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+64 added−88 removed
- tests:+1 added−22 removed
- other:+63 added−66 removed
Provenance
- Commit
3ffceff- Tree
4da01c0- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent 1
f498b66- Parent 2
75422c1
7 files changed+64 added−88 removed
modified:lib/application.js+2 added-2 removed
11 unmodified lines12 var View = require('./view');13 var http = require('http');14 var compileETag = require('./utils').compileETag;15 var compileTrust = require('./utils').compileTrust;16-var deprecate = require('./utils').deprecate;16+var deprecate = require('depd')('express');17 var resolve = require('path').resolve;18 19 /**20 * Application prototype.427 unmodified lines448 };449 450 // del -> delete alias451 452-app.del = deprecate(app.delete, 'app.del: Use app.delete instead');452+app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');453 454 /**455 * Render the given view `name` name with `options`456 * and a callback accepting an error and the93 unmodified linesmodified:lib/response.js+11 added-19 removed
1 /**2 * Module dependencies.3 */4 5+var deprecate = require('depd')('express');6 var escapeHtml = require('escape-html');7 var http = require('http');8 var path = require('path');9 var mixin = require('utils-merge');1 unmodified line11 var normalizeType = require('./utils').normalizeType;12 var normalizeTypes = require('./utils').normalizeTypes;13 var setCharset = require('./utils').setCharset;14 var contentDisposition = require('./utils').contentDisposition;14-var deprecate = require('./utils').deprecate;15 var statusCodes = http.STATUS_CODES;16 var cookie = require('cookie');17 var send = require('send');18 var basename = path.basename;166 unmodified lines185 if (2 == arguments.length) {186 // res.json(body, status) backwards compat187 if ('number' == typeof arguments[1]) {188 this.statusCode = arguments[1];189- return 'number' === typeof obj190- ? jsonNumDeprecated.call(this, obj)191- : jsonDeprecated.call(this, obj);189+ if (typeof obj === 'number') {190+ deprecate('res.json(obj, status): Use res.json(status, obj) instead');191+ } else {192+ deprecate('res.json(num, status): Use res.status(status).json(num) instead');193+ }194 } else {195 this.statusCode = obj;196 obj = arguments[1];197 }10 unmodified lines208 209 return this.send(body);210 };211 210-var jsonDeprecated = deprecate(res.json,211- 'res.json(obj, status): Use res.json(status, obj) instead');212-213-var jsonNumDeprecated = deprecate(res.json,214- 'res.json(num, status): Use res.status(status).json(num) instead');215-212 /**213 * Send JSON response with JSONP callback support.214 *215 * Examples:11 unmodified lines227 if (2 == arguments.length) {228 // res.json(body, status) backwards compat229 if ('number' == typeof arguments[1]) {230 this.statusCode = arguments[1];235- return 'number' === typeof obj236- ? jsonpNumDeprecated.call(this, obj)237- : jsonpDeprecated.call(this, obj);231+ if (typeof obj === 'number') {232+ deprecate('res.jsonp(obj, status): Use res.jsonp(status, obj) instead');233+ } else {234+ deprecate('res.jsonp(num, status): Use res.status(status).jsonp(num) instead');235+ }236 } else {237 this.statusCode = obj;238 obj = arguments[1];239 }25 unmodified lines265 266 return this.send(body);267 };268 271-var jsonpDeprecated = deprecate(res.json,272- 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead');273-274-var jsonpNumDeprecated = deprecate(res.json,275- 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead');276-269 /**270 * Transfer the file at the given `path`.271 *272 * Automatically sets the _Content-Type_ response header field.503 unmodified linesmodified:lib/utils.js+7 added-45 removed
4 unmodified lines5 var mime = require('send').mime;6 var crc32 = require('buffer-crc32');7 var crypto = require('crypto');8 var basename = require('path').basename;9-var deprecate = require('util').deprecate;9 var proxyaddr = require('proxy-addr');10+var typer = require('media-typer');11 12 /**13- * Simple detection of charset parameter in content-type14- */15-var charsetRegExp = /;\s*charset\s*=/;16-17-/**18- * Deprecate function, like core `util.deprecate`,19- * but with NODE_ENV and color support.20- *21- * @param {Function} fn22- * @param {String} msg23- * @return {Function}24- * @api private25- */26-27-exports.deprecate = function(fn, msg){28- if (process.env.NODE_ENV === 'test') return fn;29-30- // prepend module name31- msg = 'express: ' + msg;32-33- if (process.stderr.isTTY) {34- // colorize35- msg = '\x1b[31;1m' + msg + '\x1b[0m';36- }37-38- return deprecate(fn, msg);39-};40-41-/**13 * Return strong ETag for `body`.14 *15 * @param {String|Buffer} body16 * @param {String} [encoding]225 unmodified lines242 243 exports.setCharset = function(type, charset){244 if (!type || !charset) return type;245 275- var exists = charsetRegExp.test(type);246+ // parse type247+ var parsed = typer.parse(type);248 277- // removing existing charset278- if (exists) {279- var parts = type.split(';');249+ // set charset250+ parsed.parameters.charset = charset;251 281- for (var i = 1; i < parts.length; i++) {282- if (charsetRegExp.test(';' + parts[i])) {283- parts.splice(i, 1);284- break;285- }286- }287-288- type = parts.join(';');289- }290-291- return type + '; charset=' + charset;252+ // format type253+ return typer.format(parsed);254 };modified:test/support/env.js+1 added
123
process.env.NODE_ENV = 'test';process.env.NO_DEPRECATION = 'express';modified:test/utils.js-22 removed
1234567891011121314151617181920212223242526567865 unmodified lines
var utils = require('../lib/utils') , assert = require('assert');
describe('utils.deprecate(fn, msg)', function(){ var env before(function(){ env = process.env.NODE_ENV }) after(function(){ process.env.NODE_ENV = env })
it('should pass-through fn in test environment', function(){ var fn = function(){} process.env.NODE_ENV = 'test' utils.deprecate(fn).should.equal(fn) })
it('should return new fn in other environment', function(){ var fn = function(){} process.env.NODE_ENV = '' utils.deprecate(fn).should.not.equal(fn) })})
describe('utils.etag(body, encoding)', function(){ it('should support strings', function(){ utils.etag('express!') .should.eql('"zZdv4imtWD49AHEviejT6A=="')65 unmodified linesmodified:History.md+41 added
1+unreleased2+==========3+4+ * deprecate things with `depd` module5+ * use `media-typer` to alter content-type charset6+7 4.4.4 / 2014-06-208 ==================9 10 * fix `res.attachment` Unicode filenames in Safari190 unmodified lines201 - `app.router()` - returns the app Router instance202 - `app.route()` - Proxy to the app's `Router#route()` method to create a new route203 - Router & Route - public API204 205+3.12.0 / 2014-06-21206+===================207+208+ * use `media-typer` to alter content-type charset209+ * deps: connect@2.21.0210+ - deprecate `connect(middleware)` -- use `app.use(middleware)` instead211+ - deprecate `connect.createServer()` -- use `connect()` instead212+ - fix `res.setHeader()` patch to work with with get -> append -> set pattern213+ - deps: compression@~1.0.8214+ - deps: errorhandler@~1.1.1215+ - deps: express-session@~1.5.0216+ - deps: serve-index@~1.1.3217+218+3.11.0 / 2014-06-19219+===================220+221+ * deprecate things with `depd` module222+ * deps: buffer-crc32@0.2.3223+ * deps: connect@2.20.2224+ - deprecate `verify` option to `json` -- use `body-parser` module directly225+ - deprecate `verify` option to `urlencoded` -- use `body-parser` module directly226+ - deprecate things with `depd` module227+ - use `finalhandler` for final response handling228+ - use `media-typer` to parse `content-type` for charset229+ - deps: body-parser@1.4.3230+ - deps: connect-timeout@1.1.1231+ - deps: cookie-parser@1.3.1232+ - deps: csurf@1.2.2233+ - deps: errorhandler@1.1.0234+ - deps: express-session@1.4.0235+ - deps: multiparty@3.2.9236+ - deps: serve-index@1.1.2237+ - deps: type-is@1.3.1238+ - deps: vhost@2.0.0239+240 3.10.5 / 2014-06-11241 ===================242 243 * deps: connect@2.19.61443 unmodified linesmodified:package.json+2 added
26 unmodified lines272829303132333435363741 unmodified lines26 unmodified lines "dependencies": { "accepts": "~1.0.5", "buffer-crc32": "0.2.3", "debug": "1.0.2", "depd": "0.3.0", "escape-html": "1.0.1", "media-typer": "0.2.0", "methods": "1.0.1", "parseurl": "1.0.1", "proxy-addr": "1.0.1", "range-parser": "1.0.0",41 unmodified lines