Skip to content
Myr

Added req.acceptedCharsets

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 2adf020 · Browse files · 2 files+61 added−0 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+61 added−0 removed

  • tests:+37 added−0 removed
  • other:+24 added−0 removed

2 files+61 added−0 removed

modified:lib/request.js+24 added
196 unmodified lines
197 : [];198});199200/**201 * Return an array of Accepted charsets202 * ordered from highest quality to lowest.203 *204 * Examples:205 *206 * Accept-Charset: iso-8859-5;q=.2, unicode-1-1;q=0.8207 * ['unicode-1-1', 'iso-8859-5']208 *209 * @return {Array}210 * @api public211 */212213req.__defineGetter__('acceptedCharsets', function(){214 var accept = this.header('Accept-Charset');215 return accept216 ? utils217 .parseQuality(accept)218 .map(function(obj){219 return obj.value;220 })221 : [];222});223224/**225 * Return the value of param `name` when present or `defaultValue`.226 *227 * - Checks route placeholders, ex: _/user/:id_228 * - Checks query string params, ex: ?id=12
225 unmodified lines
added:test/req.acceptedCharsets.js+37 added