Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / compressible / index.js
1 /*!
2  * compressible
3  * Copyright(c) 2013 Jonathan Ong
4  * Copyright(c) 2014 Jeremiah Senkpiel
5  * Copyright(c) 2015 Douglas Christopher Wilson
6  * MIT Licensed
7  */
8
9 'use strict'
10
11 /**
12  * Module dependencies.
13  * @private
14  */
15
16 var db = require('mime-db')
17
18 /**
19  * Module variables.
20  * @private
21  */
22
23 var compressibleTypeRegExp = /^text\/|\+json$|\+text$|\+xml$/i
24 var extractTypeRegExp = /^\s*([^;\s]*)(?:;|\s|$)/
25
26 /**
27  * Module exports.
28  * @public
29  */
30
31 module.exports = compressible
32
33 /**
34  * Checks if a type is compressible.
35  *
36  * @param {string} type
37  * @return {Boolean} compressible
38  * @public
39  */
40
41 function compressible (type) {
42   if (!type || typeof type !== 'string') {
43     return false
44   }
45
46   // strip parameters
47   var match = extractTypeRegExp.exec(type)
48   var mime = match && match[1].toLowerCase()
49   var data = db[mime]
50
51   // return database information
52   if (data && data.compressible !== undefined) {
53     return data.compressible
54   }
55
56   // fallback to regexp or unknown
57   return compressibleTypeRegExp.test(mime) || undefined
58 }