A fast way to get the content type from the input string.
This is a lightweight version of jshttp/content-type for scenarios where you only want to get the content type value without parameters.
It's 90% faster; see benchmark to know more.
$ npm install @kikobeats/content-type --saveLet's say the input string is 'text/html; charset=utf-8;'.
Use the library to return the content type stripping parameters:
const contentType = require('@kikobeats/content-type')
contentType(res.headers['content-type'])
// => text/htmlRequired
Type: string
The input for getting the content type.
Type: boolean
Default: false
When strict is enabled, it will return null when the input doesn not follow conten-type header spec.
@kikobeats/content-type © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @kikobeats