jstd-web/node_modules/mime-match/example.js

18 lines
454 B
JavaScript
Raw Normal View History

2025-11-25 15:23:22 +08:00
var match = require('./');
// exact match
console.log(match('image/jpeg', 'image/jpeg'));
// --> true
// wildcard match
console.log(match('image/jpeg', 'image/*'));
// --> true
// find which of our wildcard patterns matches a specific mimetype
console.log(['application/*', 'image/*'].filter(match('image/jpeg')));
// --> ['image/*']
// charset suffix is ignored
console.log(match('application/json', 'application/json; charset=utf-8'));
// --> true