UNPKG

migme-seagull

Version:
41 lines (33 loc) 1.5 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var mime_types = { 'image/jpeg': ['jfif', 'jfif-tbnl', 'jpe', 'jpeg', 'jpg'], 'image/gif': ['gif'], 'image/png': ['png', 'x-png'], 'image/bmp': ['bm', 'bmp'] }; var MimeType = function () { function MimeType() { _classCallCheck(this, MimeType); } _createClass(MimeType, [{ key: 'fromUrl', value: function fromUrl(url) { var ext = url.split('.').pop(); var mime_type = void 0; Object.keys(mime_types).forEach(function (key) { if (mime_types[key].indexOf(ext) > -1) { mime_type = key; } }); return mime_type; } }]); return MimeType; }(); exports.default = new MimeType(); exports.mime_types = mime_types;