
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
detect-content-type
Advanced tools
detect-content-type implements the algorithm described at http://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data. It always returns a valid MIME type: if it cannot determine a mo
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Javascript module to determine the Content-Type of the given data, using the algorithm specified in the MIME Sniffing Standard.
This module is useful in cases where it is not possible to determine the Content-Type of the data using filename extension, either because file does not have an extension or the filename is not available.
npm install detect-content-type
or
yarn add detect-content-type
ES6 and above:
import detectContentType from 'detect-content-type'
Using CommonJS:
var detectContentType = require('detect-content-type')
detectContentType
takes a Buffer, and determines its Content-Type. It considers at most
512 bytes of data. detectContentType
always returns a valid MIME type. If it cannot determine a
more specific one, it returns application/octet-stream
.
let ct = detectContentType(Buffer.from("<html><body></body></html>")) // returns 'text/html; charset=utf-8'
The code in this module is ported nearly line-by-line from the http.DetectContentType method in the Go standard library.
FAQs
detect-content-type implements the algorithm described at http://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data. It always returns a valid MIME type: if it cannot determine a mo
The npm package detect-content-type receives a total of 139,276 weekly downloads. As such, detect-content-type popularity was classified as popular.
We found that detect-content-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.