Skip to content

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

chore: update validation of domains

Jonathan Summers-Muir6ffebd979f10
diff --git a/studio/components/interfaces/Forms/CommaSeperatedString.tsx b/studio/components/interfaces/Forms/CommaSeperatedString.tsx
index 05bf51f4864..c7c6f5265b7 100644
--- a/studio/components/interfaces/Forms/CommaSeperatedString.tsx
+++ b/studio/components/interfaces/Forms/CommaSeperatedString.tsx
@@ -4,6 +4,7 @@ import { EmptyListState } from 'components/ui/States'
import { useStore } from 'hooks'
import { observer } from 'mobx-react-lite'
import { useState } from 'react'
+import { object, string } from 'yup'
const CommaSeperatedString = () => {
const { authConfig, ui } = useStore()
@@ -16,6 +17,10 @@ const CommaSeperatedString = () => {
const [deleteLoading, setDeleteLoading] = useState(false)
const [selectedDomain, setSelected] = useState('')
+ let newDomainSchema = object({
+ domain: string().url().required(),
+ })
+
const DomainsForm = () => {
const [open, setOpen] = useState(false)
@@ -47,6 +52,7 @@ const CommaSeperatedString = () => {
domain: '',
}}
validateOnBlur
+ validationSchema={newDomainSchema}
onSubmit={async (values: any, { setSubmitting }: any) => {
setSubmitting(true)
try {
@@ -62,22 +68,6 @@ const CommaSeperatedString = () => {
ui.notification?.error('Failed to update domain: ', error?.message)
}
}}
- validate={(values) => {
- const errors: any = {}
- if (!values.domain) {
- errors.domain = 'A domain is required'
- } else if (
- !/^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9]+\.[a-z]+(\/[a-zA-Z0-9#]+\/?)*$/i.test(
- values.domain
- )
- ) {
- errors.domain = 'Not a valid URL. Please use http:// or https://'
- }
- if (URI_ALLOW_LIST_ARRAY.includes(values.domain)) {
- errors.domain = 'This domain is already used as a redirect URL'
- }
- return errors
- }}
>
{({ isSubmitting }: any) => {
return (