UNPKG

@coolio/http

Version:
29 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ContentType; (function (ContentType) { ContentType["BINARY"] = "application/octet-stream"; ContentType["JSON"] = "application/json"; ContentType["MULTIPART_FORM"] = "multipart/form-data"; ContentType["TEXT"] = "text/plain"; ContentType["URL_ENCODED"] = "application/x-www-form-urlencoded"; ContentType["VND_JSON"] = "application/vnd.api+json"; })(ContentType = exports.ContentType || (exports.ContentType = {})); exports.ContentTypeRegex = { JSON: /^application\/(json|.+\+json)$/, MULTIPART: /^multipart\//, TEXT: /^text\//, URL_ENCODED: /^application\/x-www-form-urlencoded$/, }; function switchContentType(contentType, map, defaultResult) { for (var key in map) { if (map.hasOwnProperty(key)) { if (exports.ContentTypeRegex[key].test(contentType)) { return map[key]; } } } return defaultResult; } exports.switchContentType = switchContentType; //# sourceMappingURL=contentType.js.map