3 * Copyright(c) 2013 Jonathan Ong
4 * Copyright(c) 2014 Jeremiah Senkpiel
5 * Copyright(c) 2015 Douglas Christopher Wilson
12 * Module dependencies.
16 var db = require('mime-db')
23 var compressibleTypeRegExp = /^text\/|\+json$|\+text$|\+xml$/i
24 var extractTypeRegExp = /^\s*([^;\s]*)(?:;|\s|$)/
31 module.exports = compressible
34 * Checks if a type is compressible.
36 * @param {string} type
37 * @return {Boolean} compressible
41 function compressible (type) {
42 if (!type || typeof type !== 'string') {
47 var match = extractTypeRegExp.exec(type)
48 var mime = match && match[1].toLowerCase()
51 // return database information
52 if (data && data.compressible !== undefined) {
53 return data.compressible
56 // fallback to regexp or unknown
57 return compressibleTypeRegExp.test(mime) || undefined