mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
Use object with null prototype for various app properties
`app.cache`, `app.engines`, and `app.settings` are now created with
`Object.create(null)` instead of `{}`.
This also updates a test to ensure that `app.locals` is created the same
way.
This commit is contained in:
parent
cd7d79f92a
commit
14439731f9
|
|
@ -61,9 +61,9 @@ var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';
|
|||
app.init = function init() {
|
||||
var router = null;
|
||||
|
||||
this.cache = {};
|
||||
this.engines = {};
|
||||
this.settings = {};
|
||||
this.cache = Object.create(null);
|
||||
this.engines = Object.create(null);
|
||||
this.settings = Object.create(null);
|
||||
|
||||
this.defaultConfiguration();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ var express = require('../')
|
|||
|
||||
describe('app', function(){
|
||||
describe('.locals', function () {
|
||||
it('should default object', function () {
|
||||
it('should default object with null prototype', function () {
|
||||
var app = express()
|
||||
assert.ok(app.locals)
|
||||
assert.strictEqual(typeof app.locals, 'object')
|
||||
assert.strictEqual(Object.getPrototypeOf(app.locals), null)
|
||||
})
|
||||
|
||||
describe('.settings', function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user