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:
@@ -3,6 +3,7 @@ import axios from 'axios';
|
|||||||
import rateLimit, { type rateLimitOptions } from 'axios-rate-limit';
|
import rateLimit, { type rateLimitOptions } from 'axios-rate-limit';
|
||||||
import { createHash } from 'crypto';
|
import { createHash } from 'crypto';
|
||||||
import { promises } from 'fs';
|
import { promises } from 'fs';
|
||||||
|
import mime from 'mime/lite';
|
||||||
import path, { join } from 'path';
|
import path, { join } from 'path';
|
||||||
|
|
||||||
type ImageResponse = {
|
type ImageResponse = {
|
||||||
@@ -269,7 +270,10 @@ class ImageProxy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const buffer = Buffer.from(response.data, 'binary');
|
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(
|
let maxAge = Number(
|
||||||
(response.headers['cache-control'] ?? '0').split('=')[1]
|
(response.headers['cache-control'] ?? '0').split('=')[1]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user