Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: bucket name validation (#34083)

hallidayo718b5a8d283d
diff --git a/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx b/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx
index a2db5c7f6db..955e12706ac 100644
--- a/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx
@@ -50,9 +50,16 @@ const CreateBucketModal = ({ visible, onClose }: CreateBucketModalProps) => {
const validate = (values: any) => {
const errors = {} as any
+
if (!values.name) {
errors.name = 'Please provide a name for your bucket'
}
+
+ if (values.name && !/^[a-z0-9.-]+$/.test(values.name)) {
+ errors.name =
+ 'The name of the bucket must only container lowercase letters, numbers, dots, and hyphens'
+ }
+
if (values.name && values.name.endsWith(' ')) {
errors.name = 'The name of the bucket cannot end with a whitespace'
}