Skip to content
Myr

Added req.acceptedLanguages

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 a8fd8cb · Browse files · 3 files+62 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

3 files+62 added−1 removed

  • tests:+38 added−1 removed
  • other:+24 added−0 removed

3 files+62 added−1 removed

modified:lib/request.js+24 added
172 unmodified lines
173 : [];174});175176/**177 * Return an array of Accepted languages178 * ordered from highest quality to lowest.179 *180 * Examples:181 *182 * Accept-Language: en;q=.5, en-us183 * ['en-us', 'en']184 *185 * @return {Array}186 * @api public187 */188189req.__defineGetter__('acceptedLanguages', function(){190 var accept = this.header('Accept-Language');191 return accept192 ? utils193 .parseQuality(accept)194 .map(function(obj){195 return obj.value;196 })197 : [];198});199200/**201 * Return the value of param `name` when present or `defaultValue`.202 *203 * - Checks route placeholders, ex: _/user/:id_204 * - Checks query string params, ex: ?id=12
225 unmodified lines
modified:test/req.accepted.js+1 added-1 removed
added:test/req.acceptedLanguages.js+37 added