Skip to content
Myr

Fix OPTIONS responses to include the HEAD method property

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

fixes #2459

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent b0f8809 · Browse files · 3 files+30 added−14 removed
This commit

State

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

Diff stats

3 files+30 added−14 removed

  • tests:+4 added−4 removed
  • other:+26 added−10 removed

3 files+30 added−14 removed

modified:lib/router/index.js+25 added-10 removed
194 unmodified lines
195 * @return {Array}196 * @api private197 */198199Router.prototype._optionsFor = function(path){200 var self = this;201 return methods.filter(function(method){202 var routes = self.map[method];203 if (!routes || 'options' == method) return;204 for (var i = 0, len = routes.length; i < len; ++i) {205 if (routes[i].match(path)) return true;199Router.prototype._optionsFor = function _optionsFor(path) {200 var options = [];201202 for (var i = 0; i < methods.length; i++) {203 var method = methods[i];204205 if (method === 'options') continue;206207 var routes = this.map[method];208209 // HEAD methods include GET routes210 if (!routes && method === 'head') {211 routes = this.map.get;212 }207 }).map(function(method){208 return method.toUpperCase();209 });213214 if (!routes) continue;215216 for (var j = 0; j < routes.length; j++) {217 if (routes[j].match(path)) {218 options.push(method.toUpperCase());219 break;220 }221 }222 }223224 return options.sort();225};226227/**228 * Attempt to match a route for `req`
108 unmodified lines
modified:test/app.options.js+4 added-4 removed
modified:History.md+1 added
13.x2===34 * Fix `OPTIONS` responses to include the `HEAD` method property5 * Use `readline` for prompt in `express(1)`6 * deps: commander@2.6.07 * deps: connect@2.28.18 - deps: body-parser@~1.10.1
1932 unmodified lines