Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
The ext-name npm package is used to get the file extension name from a given file path or URL. It is a simple utility that helps in extracting the extension part of a file name.
Get file extension from a file path
This feature allows you to extract the file extension and its corresponding MIME type from a given file path.
const extName = require('ext-name');
const filePath = 'example/file.txt';
const extension = extName(filePath);
console.log(extension); // { ext: 'txt', mime: 'text/plain' }
Get file extension from a URL
This feature allows you to extract the file extension and its corresponding MIME type from a given URL.
const extName = require('ext-name');
const url = 'http://example.com/file.txt';
const extension = extName(url);
console.log(extension); // { ext: 'txt', mime: 'text/plain' }
The mime-types package provides a comprehensive list of MIME types and their associated file extensions. It is more extensive than ext-name and can be used to look up MIME types based on file extensions and vice versa.
The path module is a built-in Node.js module that provides utilities for working with file and directory paths. It includes a method called extname which can be used to extract the file extension from a file path. However, it does not provide MIME type information.
The mime package is used to look up the MIME type of a file based on its extension. It is similar to ext-name but focuses more on MIME type lookups and conversions.
Get the file extension and MIME type from a file
$ npm install --save ext-name
const extName = require('ext-name');
console.log(extName('foobar.tar'));
//=> [{ext: 'tar', mime: 'application/x-tar'}]
console.log(extName.mime('application/x-tar'));
//=> [{ext: 'tar', mime: 'application/x-tar'}]
Returns an Array
with objects with the file extension and MIME type.
Type: string
Get the extension and MIME type from a filename.
Returns an Array
with objects with the file extension and MIME type.
Type: string
Get the extension and MIME type from a MIME type.
MIT © Kevin Mårtensson
FAQs
Get the file extension and MIME type from a file
The npm package ext-name receives a total of 2,299,507 weekly downloads. As such, ext-name popularity was classified as popular.
We found that ext-name 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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.