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 base64 validation regex in StorageClient to support a wider range of base64 strings

Kiran Kdd8833a1bc6e
diff --git a/apps/web/lib/storage.ts b/apps/web/lib/storage.ts
index fb2e57d98d..2244f26c4e 100644
--- a/apps/web/lib/storage.ts
+++ b/apps/web/lib/storage.ts
@@ -100,7 +100,8 @@ class StorageClient {
}
private isBase64(str: string): boolean {
- const regex = /^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,([^\s]*)$/;
+ const regex =
+ /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
return regex.test(str);
}