1 Star 0 Fork 0

animalcoder/Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
animalcoder 提交于 2020-03-17 14:52 +08:00 . Vueinit
/*!
* compressible
* Copyright(c) 2013 Jonathan Ong
* Copyright(c) 2014 Jeremiah Senkpiel
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict'
/**
* Module dependencies.
* @private
*/
var db = require('mime-db')
/**
* Module variables.
* @private
*/
var COMPRESSIBLE_TYPE_REGEXP = /^text\/|\+(?:json|text|xml)$/i
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
/**
* Module exports.
* @public
*/
module.exports = compressible
/**
* Checks if a type is compressible.
*
* @param {string} type
* @return {Boolean} compressible
* @public
*/
function compressible (type) {
if (!type || typeof type !== 'string') {
return false
}
// strip parameters
var match = EXTRACT_TYPE_REGEXP.exec(type)
var mime = match && match[1].toLowerCase()
var data = db[mime]
// return database information
if (data && data.compressible !== undefined) {
return data.compressible
}
// fallback to regexp or unknown
return COMPRESSIBLE_TYPE_REGEXP.test(mime) || undefined
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/animalcoder/Vue.git
git@gitee.com:animalcoder/Vue.git
animalcoder
Vue
Vue
master

搜索帮助