django-vue3-admin-web/node_modules/mime-match/index.js
2025-10-20 21:21:14 +08:00

25 lines
578 B
JavaScript

var wildcard = require('wildcard');
var reMimePartSplit = /[\/\+\.]/;
/**
# mime-match
A simple function to checker whether a target mime type matches a mime-type
pattern (e.g. image/jpeg matches image/jpeg OR image/*).
## Example Usage
<<< example.js
**/
module.exports = function(target, pattern) {
function test(pattern) {
var result = wildcard(pattern, target, reMimePartSplit);
// ensure that we have a valid mime type (should have two parts)
return result && result.length >= 2;
}
return pattern ? test(pattern.split(';')[0]) : test;
};