The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: strict regex check now also accepting numbers
Jonathan Summers-Muir9561a7f0ddca
diff --git a/studio/components/interfaces/Auth/Auth.constants.ts b/studio/components/interfaces/Auth/Auth.constants.tsindex b1a6884e257..1c403b8efba 100644--- a/studio/components/interfaces/Auth/Auth.constants.ts+++ b/studio/components/interfaces/Auth/Auth.constants.ts@@ -2,13 +2,14 @@// localhost - if we can combine these 2 together that'll be great but my regex-foo isn't too strong// Regex from: https://stackoverflow.com/a/68002755/4807782+// modified to accept numbers in the body of domain though// examples of matches:// "vercel.com"// "www.vercel.com"// "uptime-monitor-fe.vercel.app"// "https://uptime-monitor-fe.vercel.app/"export const domainRegexStrict =- /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/m+ /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm// [Joshen] This regex allows for localhost as well, less strictexport const webRegex = /^(ftp|http|https):\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[.\w]*)*$/i@@ -16,4 +17,6 @@ export const webRegex = /^(ftp|http|https):\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[.\w]*// iOS deep linking scheme https://benoitpasquier.com/deep-linking-url-scheme-ios/export const appRegex = /^[a-z0-9]+([.][a-z0-9]+)*:\/(\/[-a-z0-9._~!$&'()*+,;=:@%]+)+$/i+// combine the above regexes+export const domainRegex = new RegExp(`(${webRegex.source})|(${appRegex.source})`, 'i')diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.ts b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.tsindex 75ac33df702..f129e3fb283 100644--- a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.ts+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.ts@@ -1,18 +1,3 @@-/**- * domain and IP address regex- *- * example of matches:- *- * "vercel.com"- * "www.vercel.com"- * "uptime-monitor-fe.vercel.app"- * "https://uptime-monitor-fe.vercel.app/"- * "127.0.0.0"- *- */-export const domainRegex =- /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$|^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)$/gm-export const defaultDisabledSmtpFormValues = {SMTP_ADMIN_EMAIL: null,SMTP_SENDER_NAME: null,diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxindex 1b2e8ed0119..0e9b11cde7e 100644--- a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -12,7 +12,8 @@ import {FormSectionContent,FormSectionLabel,} from 'components/ui/Forms'-import { domainRegex, defaultDisabledSmtpFormValues } from './SmtpForm.constants'+import { defaultDisabledSmtpFormValues } from './SmtpForm.constants'+import { domainRegexStrict } from './../Auth.constants'import { isSmtpEnabled, generateFormValues } from './SmtpForm.utils'const SmtpForm = () => {@@ -50,7 +51,7 @@ const SmtpForm = () => {},then: (schema) =>schema- .matches(domainRegex, 'Must be a valid URL or IP address')+ .matches(domainRegexStrict, 'Must be a valid URL or IP address').required('Host URL is required.'),otherwise: (schema) => schema,}),