fix(imagecache): fix avatar cache folder creation (#1581)

This fixes a regression caused by #1520 which broke the file extension detection thereby breaking
avatars
This commit is contained in:
fallenbagel
2025-04-12 02:24:13 +08:00
committed by GitHub
parent b7b05d31a5
commit 355b76de5c

View File

@@ -3,6 +3,7 @@ import axios from 'axios';
import rateLimit, { type rateLimitOptions } from 'axios-rate-limit';
import { createHash } from 'crypto';
import { promises } from 'fs';
import mime from 'mime/lite';
import path, { join } from 'path';
type ImageResponse = {
@@ -269,7 +270,10 @@ class ImageProxy {
});
const buffer = Buffer.from(response.data, 'binary');
const extension = path.split('.').pop() ?? '';
const contentType = response.headers['content-type'] || '';
const extension = mime.getExtension(contentType) || '';
let maxAge = Number(
(response.headers['cache-control'] ?? '0').split('=')[1]
);