file-type
Advanced tools
Comparing version 18.2.0 to 18.2.1
27
core.js
@@ -614,13 +614,20 @@ import {Buffer} from 'node:buffer'; | ||
if (this.checkString('%PDF')) { | ||
await tokenizer.ignore(1350); | ||
const maxBufferSize = 10 * 1024 * 1024; | ||
const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size)); | ||
await tokenizer.readBuffer(buffer, {mayBeLess: true}); | ||
try { | ||
await tokenizer.ignore(1350); | ||
const maxBufferSize = 10 * 1024 * 1024; | ||
const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size)); | ||
await tokenizer.readBuffer(buffer, {mayBeLess: true}); | ||
// Check if this is an Adobe Illustrator file | ||
if (buffer.includes(Buffer.from('AIPrivateData'))) { | ||
return { | ||
ext: 'ai', | ||
mime: 'application/postscript', | ||
}; | ||
// Check if this is an Adobe Illustrator file | ||
if (buffer.includes(Buffer.from('AIPrivateData'))) { | ||
return { | ||
ext: 'ai', | ||
mime: 'application/postscript', | ||
}; | ||
} | ||
} catch (error) { | ||
// Swallow end of stream error if file is too small for the Adobe AI check | ||
if (!(error instanceof strtok3.EndOfStreamError)) { | ||
throw error; | ||
} | ||
} | ||
@@ -627,0 +634,0 @@ |
{ | ||
"name": "file-type", | ||
"version": "18.2.0", | ||
"version": "18.2.1", | ||
"description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
83826
2154