{"_id":"content-type-parser","_rev":"88687","name":"content-type-parser","description":"Parse the value of the Content-Type header","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"domenic","email":""}],"time":{"modified":"2021-06-03T10:28:50.000Z","created":"2016-10-15T21:28:32.588Z","1.0.2":"2017-10-23T00:04:15.009Z","1.0.1":"2016-10-15T22:18:21.484Z","1.0.0":"2016-10-15T21:28:32.588Z"},"users":{},"author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"repository":{"type":"git","url":"git+https://github.com/jsdom/content-type-parser.git"},"versions":{"1.0.2":{"name":"content-type-parser","description":"Parse the value of the Content-Type header","keywords":["content-type","http"],"version":"1.0.2","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/content-type-parser.git"},"main":"lib/content-type-parser.js","files":["lib/"],"scripts":{"test":"mocha","lint":"eslint lib test"},"devDependencies":{"eslint":"^3.8.0","mocha":"^3.1.2"},"gitHead":"00a5e0cb56828d6d231bf675a44f0ce7de5667f9","bugs":{"url":"https://github.com/jsdom/content-type-parser/issues"},"homepage":"https://github.com/jsdom/content-type-parser#readme","_id":"content-type-parser@1.0.2","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"caabe80623e63638b2502fd4c7f12ff4ce2352e7","size":3144,"noattachment":false,"key":"/content-type-parser/-/content-type-parser-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/content-type-parser/download/content-type-parser-1.0.2.tgz"},"maintainers":[{"name":"domenic","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/content-type-parser-1.0.2.tgz_1508717054023_0.5955320314969867"},"directories":{},"publish_time":1508717055009,"_hasShrinkwrap":false,"_cnpm_publish_time":1508717055009},"1.0.1":{"name":"content-type-parser","description":"Parse the value of the Content-Type header","keywords":["content-type","http"],"version":"1.0.1","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"WTFPL","repository":{"type":"git","url":"git+https://github.com/jsdom/content-type-parser.git"},"main":"lib/content-type-parser.js","files":["lib/"],"scripts":{"test":"mocha","lint":"eslint lib test"},"devDependencies":{"eslint":"^3.8.0","mocha":"^3.1.2"},"gitHead":"a5581b8a0dfd7c358b71f22f387ca3308e6eb502","bugs":{"url":"https://github.com/jsdom/content-type-parser/issues"},"homepage":"https://github.com/jsdom/content-type-parser#readme","_id":"content-type-parser@1.0.1","_shasum":"c3e56988c53c65127fb46d4032a3a900246fdc94","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"c3e56988c53c65127fb46d4032a3a900246fdc94","size":2919,"noattachment":false,"key":"/content-type-parser/-/content-type-parser-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/content-type-parser/download/content-type-parser-1.0.1.tgz"},"maintainers":[{"name":"domenic","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/content-type-parser-1.0.1.tgz_1476569899741_0.47508528595790267"},"directories":{},"publish_time":1476569901484,"_cnpm_publish_time":1476569901484,"_hasShrinkwrap":false},"1.0.0":{"name":"content-type-parser","description":"Parse the value of the Content-Type header","keywords":["content-type","http"],"version":"1.0.0","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"WTFPL","repository":{"type":"git","url":"git+https://github.com/jsdom/content-type-parser.git"},"main":"lib/content-type-parser.js","files":["lib/"],"scripts":{"test":"mocha","lint":"eslint lib test"},"devDependencies":{"eslint":"^3.8.0","mocha":"^3.1.2"},"gitHead":"023de15a0ae8e30c0cc7f75f5c7394475c656dd8","bugs":{"url":"https://github.com/jsdom/content-type-parser/issues"},"homepage":"https://github.com/jsdom/content-type-parser#readme","_id":"content-type-parser@1.0.0","_shasum":"f4f305e21d00475c1a6a8e0e687690b717b0572b","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"f4f305e21d00475c1a6a8e0e687690b717b0572b","size":1939,"noattachment":false,"key":"/content-type-parser/-/content-type-parser-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/content-type-parser/download/content-type-parser-1.0.0.tgz"},"maintainers":[{"name":"domenic","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/content-type-parser-1.0.0.tgz_1476566910657_0.6183169237338006"},"directories":{},"publish_time":1476566912588,"_cnpm_publish_time":1476566912588,"_hasShrinkwrap":false}},"readme":"# Parse `Content-Type` Header Strings\n\nThis package will parse the [`Content-Type`](https://tools.ietf.org/html/rfc7231#section-3.1.1.1) header field into an introspectable data structure, whose parameters can be manipulated:\n\n```js\nconst contentTypeParser = require(\"content-type-parser\");\n\nconst contentType = contentTypeParser(`Text/HTML;Charset=\"utf-8\"`);\n\nconsole.assert(contentType.toString() === \"text/html;charset=utf-8\");\n\nconsole.assert(contentType.type === \"text\");\nconsole.assert(contentType.subtype === \"html\");\nconsole.assert(contentType.get(\"charset\") === \"utf-8\");\n\ncontentType.set(\"charset\", \"windows-1252\");\nconsole.assert(contentType.get(\"charset\") === \"windows-1252\");\nconsole.assert(contentType.toString() === \"text/html;charset=windows-1252\");\n\nconsole.assert(contentType.isHTML() === true);\nconsole.assert(contentType.isXML() === false);\nconsole.assert(contentType.isText() === true);\n```\n\nNote how parsing will lowercase the type, subtype, and parameter name tokens (but not parameter values).\n\nIf the passed string cannot be parsed as a content-type, `contentTypeParser` will return `null`.\n\n## `ContentType` instance API\n\nThis package's main module's default export will return an instance of the `ContentType` class, which has the following public APIs:\n\n### Properties\n\n- `type`: the top-level media type, e.g. `\"text\"`\n- `subtype`: the subtype, e.g. `\"html\"`\n- `parameterList`: an array of `{ separator, key, value }` pairs representing the parameters. The `separator` field contains any whitespace, not just the `;` character.\n\n### Parameter manipulation\n\nIn general you should not directly manipulate `parameterList`. Instead, use the following APIs:\n\n- `get(\"key\")`: returns the value of the parameter with the given key, or `undefined` if no such parameter is present\n- `set(\"key\", \"value\")`: adds the given key/value pair to the parameter list, or overwrites the existing value if an entry already existed\n\nBoth of these will lowercase the keys.\n\n### MIME type tests\n\n- `isHTML()`: returns true if this instance's MIME type is [the HTML MIME type](https://html.spec.whatwg.org/multipage/infrastructure.html#html-mime-type), `\"text/html\"`\n- `isXML()`: returns true if this instance's MIME type is [an XML MIME type](https://html.spec.whatwg.org/multipage/infrastructure.html#xml-mime-type)\n- `isText()`: returns true if this instance's top-level media type is `\"text\"`\n\n### Serialization\n\n- `toString()` will return a canonicalized representation of the content-type, re-built from the parsed components\n\n## Credits\n\nThis package was originally based on the excellent work of [@nicolashenry](https://github.com/nicolashenry), [in jsdom](https://github.com/tmpvar/jsdom/blob/16fd85618f2705d181232f6552125872a37164bc/lib/jsdom/living/helpers/headers.js). It has since been pulled out into this separate package.\n","_attachments":{},"homepage":"https://github.com/jsdom/content-type-parser#readme","bugs":{"url":"https://github.com/jsdom/content-type-parser/issues"},"license":"MIT"}