feat: expect webp from void.cat

This commit is contained in:
Kieran 2023-01-30 18:47:16 +00:00
parent e21494cc2d
commit 0a6339ddf1
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -28,8 +28,11 @@ export default async function VoidUpload(file: File | Blob, filename: string): P
let rsp: VoidUploadResponse = await req.json(); let rsp: VoidUploadResponse = await req.json();
if (rsp.ok) { if (rsp.ok) {
let ext = filename.match(FileExtensionRegex); let ext = filename.match(FileExtensionRegex);
if(rsp.file?.metadata?.mimeType === "image/webp") {
ext = ["", "webp"];
}
return { return {
url: rsp.file?.meta?.url ?? `${VoidCatHost}/d/${rsp.file?.id}${ext ? `.${ext[1]}` : ""}` url: rsp.file?.metadata?.url ?? `${VoidCatHost}/d/${rsp.file?.id}${ext ? `.${ext[1]}` : ""}`
} }
} else { } else {
return { return {
@ -50,7 +53,7 @@ export type VoidUploadResponse = {
export type VoidFile = { export type VoidFile = {
id: string, id: string,
meta?: VoidFileMeta metadata?: VoidFileMeta
} }
export type VoidFileMeta = { export type VoidFileMeta = {