source: trip-planner-front/node_modules/compressible/index.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
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
16var db = require('mime-db')
17
18/**
19 * Module variables.
20 * @private
21 */
22
23var COMPRESSIBLE_TYPE_REGEXP = /^text\/|\+(?:json|text|xml)$/i
24var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
25
26/**
27 * Module exports.
28 * @public
29 */
30
31module.exports = compressible
32
33/**
34 * Checks if a type is compressible.
35 *
36 * @param {string} type
37 * @return {Boolean} compressible
38 * @public
39 */
40
41function compressible (type) {
42 if (!type || typeof type !== 'string') {
43 return false
44 }
45
46 // strip parameters
47 var match = EXTRACT_TYPE_REGEXP.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 COMPRESSIBLE_TYPE_REGEXP.test(mime) || undefined
58}
Note: See TracBrowser for help on using the repository browser.