Skip to content
Myr

Added req.acceptsCharset()

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent ff9b82c · Browse files · 2 files+67 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+67 added−1 removed

  • tests:+49 added−0 removed
  • other:+18 added−1 removed

2 files+67 added−1 removed

modified:lib/request.js+18 added-1 removed
96 unmodified lines
97 return RegExp.$1 || RegExp.$2;98};99100/**101 * Check if the given `type` is acceptable.101 * Check if the given `type` is acceptable,102 * otherwise you should respond with 406 "Not Acceptable".103 *104 * Examples:105 * 106 * // Accept: text/html
20 unmodified lines
127 return utils.accepts(type, this.header('Accept'));128};129130/**131 * Check if the given `charset` is acceptable,132 * otherwise you should respond with 406 "Not Acceptable".133 *134 * @param {String} charset135 * @return {Boolean}136 * @api public137 */138139req.acceptsCharset = function(charset){140 var accepted = this.acceptedCharsets;141 return accepted.length142 ? ~accepted.indexOf(charset)143 : true;144};145146/**147 * Return an array of Accepted media types148 * ordered from highest quality to lowest.149 *150 * Examples:
299 unmodified lines
added:test/req.acceptsCharset.js+49 added