diff --git a/lib/application.js b/lib/application.js index 310e6dfef21..efbb7c4653f 100644 --- a/lib/application.js +++ b/lib/application.js @@ -118,7 +118,7 @@ app.defaultConfiguration = function defaultConfiguration() { Object.setPrototypeOf(this.request, parent.request) Object.setPrototypeOf(this.response, parent.response) Object.setPrototypeOf(this.engines, parent.engines) - Object.setPrototypeOf(this.settings, parent.settings) + this.settings = parent.settings }); // setup locals @@ -397,8 +397,8 @@ app.set = function set(setting, val) { */ app.path = function path() { - return this.parent - ? this.parent.path() + this.mountpath + return this.parent != null + ? this.mountpath + this.parent.path() : ''; }; @@ -533,10 +533,10 @@ app.render = function render(name, options, callback) { } // merge options - var renderOptions = { ...this.locals, ...opts._locals, ...opts }; + var renderOptions = Object.assign(this.locals, opts._locals, opts); // set .cache unless explicitly provided - if (renderOptions.cache == null) { + if (renderOptions.cache === undefined || renderOptions.cache === null) { renderOptions.cache = this.enabled('view cache'); } diff --git a/lib/request.js b/lib/request.js index c0506334ce2..8bfead056d0 100644 --- a/lib/request.js +++ b/lib/request.js @@ -390,7 +390,7 @@ defineGetter(req, 'subdomains', function subdomains() { ? hostname.split('.').reverse() : [hostname]; - return subdomains.slice(offset); + return subdomains.slice(offset-1) }); /** diff --git a/lib/response.js b/lib/response.js index 0d5a4ae4d4d..5c69b01162d 100644 --- a/lib/response.js +++ b/lib/response.js @@ -323,7 +323,7 @@ res.jsonp = function jsonp(obj) { */ res.sendStatus = function sendStatus(statusCode) { - var body = statuses.message[statusCode] || String(statusCode) + const body = statuses.message[statusCode] || String(statusCode) this.status(statusCode); this.type('txt'); @@ -714,7 +714,7 @@ res.get = function(field){ res.clearCookie = function clearCookie(name, options) { // Force cookie expiration by setting expires to the past - const opts = { path: '/', ...options, expires: new Date(1)}; + var opts = { expires: new Date(1), path: '/', ...options }; // ensure maxAge is not passed delete opts.maxAge @@ -746,7 +746,7 @@ res.clearCookie = function clearCookie(name, options) { */ res.cookie = function (name, value, options) { - var opts = { ...options }; + var opts = options || {}; var secret = this.req.secret; var signed = opts.signed;