Skip to content
Myr

Merge pull request #1723 from gmethvin/accepts

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

Make req.accepts take an argument list

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 8a1e865, 3ddd8e6 · Browse files · 2 files+17 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+17 added−1 removed

  • tests:+13 added−0 removed
  • other:+4 added−1 removed

2 files+17 added−1 removed

modified:lib/request.js+4 added-1 removed
61 unmodified lines
62 *63 * The `type` value may be a single mime type string64 * such as "application/json", the extension name65 * such as "json", a comma-delimted list such as "json, html, text/plain",66 * an argument list such as `"json", "html", "text/plain"`,67 * or an array `["json", "html", "text/plain"]`. When a list68 * or array is given the _best_ match, if any is returned.69 *70 * Examples:
18 unmodified lines
89 * // => undefined90 *91 * // Accept: text/*;q=.5, application/json92 * req.accepts(['html', 'json']);93 * req.accepts('html', 'json');94 * req.accepts('html, json');95 * // => "json"96 *97 * @param {String|Array} type(s)
1 unmodified line
99 * @api public100 */101102req.accepts = function(type){103 var args = arguments.length > 1 ? [].slice.apply(arguments) : type;101 return utils.accepts(type, this.get('Accept'));104 return utils.accepts(args, this.get('Accept'));105};106107/**108 * Check if the given `encoding` is accepted.
421 unmodified lines
modified:test/req.accepts.js+13 added