Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update misc.ts

Kiran K2e807be981e3
diff --git a/apps/web/lib/zod/schemas/misc.ts b/apps/web/lib/zod/schemas/misc.ts
index 4d8a227fbd..4faeb3e6e7 100644
--- a/apps/web/lib/zod/schemas/misc.ts
+++ b/apps/web/lib/zod/schemas/misc.ts
@@ -10,6 +10,14 @@ export const roleSchema = z
.enum(roles)
.describe("The role of the authenticated user in the workspace.");
+const allowedImageTypes = [
+ "image/png",
+ "image/jpeg",
+ "image/jpg",
+ "image/gif",
+ "image/webp",
+];
+
// A boolean query schema that coerces the value to a boolean
export const booleanQuerySchema = z
.enum(["true", "false"])
@@ -66,18 +74,10 @@ export const base64ImageSchema = z
}
try {
- const allowedTypes = [
- "image/png",
- "image/jpeg",
- "image/jpg",
- "image/gif",
- "image/webp",
- ];
-
const buffer = new Uint8Array(Buffer.from(base64Data, "base64"));
const fileType = await fileTypeFromBuffer(buffer);
- return fileType && allowedTypes.includes(fileType.mime);
+ return fileType && allowedImageTypes.includes(fileType.mime);
} catch (e) {
return false;
}