Skip to content

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

fix: trim whitespace from the front and back of project name

Vlăduț Voicu8499bc86685b
diff --git a/studio/components/interfaces/Settings/General/General.tsx b/studio/components/interfaces/Settings/General/General.tsx
index 3145838560e..f7fc98356d1 100644
--- a/studio/components/interfaces/Settings/General/General.tsx
+++ b/studio/components/interfaces/Settings/General/General.tsx
@@ -25,7 +25,9 @@ const General: FC<Props> = ({}) => {
const canUpdateProject = checkPermissions(PermissionAction.UPDATE, 'projects')
const onSubmit = async (values: any, { resetForm }: any) => {
- const response = await post(`${API_URL}/projects/${project?.ref}/update`, { name: values.name })
+ const response = await post(`${API_URL}/projects/${project?.ref}/update`, {
+ name: values.name.trim(),
+ })
if (response.error) {
ui.setNotification({
category: 'error',
diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsx
index 9d37c852e5a..919e2b3ea23 100644
--- a/studio/pages/new/[slug].tsx
+++ b/studio/pages/new/[slug].tsx
@@ -162,7 +162,7 @@ const Wizard: NextPageWithLayout = () => {
const data: Record<string, any> = {
cloud_provider: PROVIDERS.AWS.id, // hardcoded for DB instances to be under AWS
org_id: currentOrg?.id,
- name: projectName,
+ name: projectName.trim(),
db_pass: dbPass,
db_region: dbRegion,
db_pricing_tier_id: (PRICING_TIER_PRODUCT_IDS as any)[dbTier],
diff --git a/studio/pages/new/index.tsx b/studio/pages/new/index.tsx
index fb8c96b2bb2..8ca1dcfd02d 100644
--- a/studio/pages/new/index.tsx
+++ b/studio/pages/new/index.tsx
@@ -42,8 +42,7 @@ const Wizard: NextPageWithLayout = () => {
const [newOrgLoading, setNewOrgLoading] = useState(false)
function validateOrgName(name: any) {
- const value = name ? name.trim() : ''
- return value.length >= 1
+ return name.length >= 1
}
function onOrgNameChange(e: any) {
@@ -60,7 +59,8 @@ const Wizard: NextPageWithLayout = () => {
async function onClickSubmit(e: any) {
e.preventDefault()
- const isOrgNameValid = validateOrgName(orgName)
+ const trimmedOrgName = orgName ? orgName.trim() : ''
+ const isOrgNameValid = validateOrgName(trimmedOrgName)
if (!isOrgNameValid) {
ui.setNotification({ category: 'error', message: 'Organization name is empty' })
return
@@ -68,7 +68,7 @@ const Wizard: NextPageWithLayout = () => {
setNewOrgLoading(true)
const response = await post(`${API_URL}/organizations`, {
- name: orgName,
+ name: trimmedOrgName,
kind: orgKind,
...(orgKind == 'COMPANY' ? { size: orgSize } : {}),
})