Skip to content
Myr

Request#accepts() returns true when Accept is not present

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent bfb6cec · Browse files · 2 files+28 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+28 added−1 removed

  • tests:+21 added−0 removed
  • other:+7 added−1 removed

2 files+28 added−1 removed

modified:lib/express/request.js+7 added-1 removed
147 unmodified lines
148 /**149 * Check if Accept header includes the mime type150 * for the given _path_, which calls mime().151 *152 * When no Accept header is present true will be153 * returned as stated in the HTTP specification.154 *155 * @param {string} path156 * @return {bool}157 * @see mime()158 * @api public159 */160161 accepts: function(path) {158 return this.header('accept').indexOf(mime(path)) != -1162 return this.header('accept') ? 163 this.header('accept').indexOf(mime(path)) !== -1 :164 true165 },166167 /**168 * Set response status to _code_.
94 unmodified lines
modified:spec/spec.request.js+21 added