How to use mime-format - 2 common examples

To help you get started, we’ve selected a few mime-format examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postmanlabs / postman-collection / lib / content-info / index.js View on Github external
getMimeInfo = function (contentType, response) {
        var normalized,
            detected;

        if (!contentType) {
            detected = fileType(response);
            detected && (contentType = detected.mime);
        }

        // if contentType is not detected set text/plain as default
        if (!contentType) {
            contentType = CONTENT_TYPE_TEXT_PLAIN;
        }

        normalized = mimeFormat.lookup(contentType);

        return {
            mimeType: normalized.type, // sanitised mime type base
            mimeFormat: normalized.format, // format specific to the type returned
            charset: normalized.charset || CHARSET_UTF8,
            extension: mimeType.extension(normalized.source) || E
        };
    },
github postmanlabs / postman-collection / lib / collection / response.js View on Github external
mimeInfo: function (type, disposition) {
        Header.isHeader(type) && (type = type.value);
        Header.isHeader(disposition) && (disposition = disposition.value);

        // validate that the content type exists
        if (!(type && _.isString(type))) { return; }

        var normalised = mimeFormat.lookup(type),
            info = {};

        _.assign(info, {
            type: normalised.type, // sanitised mime type base
            format: normalised.format, // format specific to the type returned
            name: DEFAULT_RESPONSE_FILENAME,
            ext: mimeType.extension(normalised.source) || E, // file extension from sanitised content type
            charset: normalised.charset || UTF8,

            // also storing some meta info for possible debugging
            _originalContentType: type, // the user provided mime type
            _sanitisedContentType: normalised.source, // sanitised mime type
            _accuratelyDetected: !normalised.orphan // this being true implies worse case (raw render)
        });

        // build the file name from extension

mime-format

Database to mime-format based on content-type header and content

Apache-2.0
Latest version published 4 years ago

Package Health Score

66 / 100
Full package analysis

Popular mime-format functions