Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/asset

Package Overview
Dependencies
Maintainers
1
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/asset - npm Package Compare versions

Comparing version 3.1.10 to 3.1.11

support/fixtures/empty

2

package.json
{
"name": "@travetto/asset",
"version": "3.1.10",
"version": "3.1.11",
"description": "Modular library for storing and retrieving binary assets",

@@ -5,0 +5,0 @@ "keywords": [

@@ -52,3 +52,7 @@ import fs from 'fs/promises';

const buffer = await this.readChunk(filePath, 4100);
return fileType.fromBuffer(buffer);
const matched = await fileType.fromBuffer(buffer);
if (matched?.mime === 'video/mp4' && filePath.endsWith('.m4a')) {
return { ext: '.m4a', mime: 'audio/mpeg' };
}
return matched;
}

@@ -63,3 +67,4 @@

const ext = mime.getExtension(type);
const newFile = filePath.replace(/[.][^.]+$/, ext!);
const baseName = path.basename(filePath, path.extname(filePath));
const newFile = `${baseName}.${ext}`;

@@ -78,12 +83,11 @@ if (filePath !== newFile) {

static async resolveFileType(pth: string): Promise<string> {
let contentType = path.extname(pth);
const detected = await this.detectFileType(pth);
let contentType: string | undefined | null = undefined;
if (detected) {
if (!detected || detected.mime === 'application/octet-stream') {
contentType = mime.getType(pth);
} else {
contentType = detected.mime;
} else {
contentType = mime.getType(pth) ?? contentType;
}
return contentType;
return contentType ?? 'application/octet-stream';
}

@@ -103,3 +107,4 @@

filename = path.basename(file);
if (!filename.includes('.')) {
const extName = path.extname(file);
if (!extName) {
const ext = mime.getExtension(contentType);

@@ -106,0 +111,0 @@ if (ext) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc