all files / modules/extensions/ acceptLanguage.js

88.89% Statements 8/9
50% Branches 1/2
66.67% Functions 2/3
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                
const d = require("describe-property");
const AcceptLanguage = require("../headers/AcceptLanguage");
 
module.exports = function (mach) {
    Object.defineProperties(mach.Connection.prototype, {
 
    /**
     * Returns true if the request indicates that the client accepts
     * the given content language.
     */
        acceptsLanguage: d(function (language) {
            return this.request.acceptsLanguage(language);
        })
 
    });
 
    Object.defineProperties(mach.Message.prototype, {
 
    /**
     * Returns true if the client accepts the given content language.
     */
        acceptsLanguage: d(function (language) {
            Eif (!this._acceptLanguageHeader) {
                this._acceptLanguageHeader = new AcceptLanguage(this.headers["Accept-Language"]);
            }
 
            return this._acceptLanguageHeader.accepts(language);
        })
 
    });
};