1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-05 10:18:38 +09:00
* Resolve #5688

* あああああ

* 😇

* :thinking_face:

* Update detect-mine.ts

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
Satsuki Yanagi 2020-01-07 23:34:17 +09:00 committed by syuilo
parent 90cfd87f46
commit 8aafafe416

View File

@ -1,15 +1,15 @@
import * as fs from 'fs';
import fileType = require('file-type');
import checkSvg from '../misc/check-svg';
const FileType = require('file-type');
export async function detectMine(path: string) {
return new Promise<[string, string | null]>((res, rej) => {
const readable = fs.createReadStream(path);
readable
.on('error', rej)
.once('data', (buffer: Buffer) => {
.once('data', async (buffer: Buffer) => {
readable.destroy();
const type = fileType(buffer);
const type = await FileType.fromBuffer(buffer);
if (type) {
if (type.mime == 'application/xml' && checkSvg(path)) {
res(['image/svg+xml', 'svg']);