mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Feature ## What is the current behavior? Functions page on self-hosted differs from Platform ## What is the new behavior? Adds the possibility to try/test functions in Self-Host version. ## Summary by CodeRabbit * **Bug Fixes** * Improved edge function URL validation so testing works reliably both on-platform and off-platform, including proper URL handling for local setups. * **UI Improvements** * Moved the Test button in the edge functions interface for more consistent layout while preserving its behavior. * **Tests** * Expanded tests to cover platform-aware URL validation scenarios. --------- Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
24 lines
787 B
TypeScript
24 lines
787 B
TypeScript
const NIMBUS_PROD_PROJECTS_URL = process.env.NIMBUS_PROD_PROJECTS_URL
|
|
|
|
export const isValidEdgeFunctionURL = (url: string, isPlatform: boolean) => {
|
|
if (NIMBUS_PROD_PROJECTS_URL !== undefined) {
|
|
const apexDomain = NIMBUS_PROD_PROJECTS_URL.replace('https://*.', '').replace(/\./g, '\\.')
|
|
const nimbusRegex = new RegExp('^https://[a-z]*\\.' + apexDomain + '/functions/v[0-9]{1}/.*$')
|
|
return nimbusRegex.test(url)
|
|
}
|
|
|
|
if (!isPlatform) {
|
|
const regexValidLocalEdgeFunctionURL = new RegExp(
|
|
'^https?://[^\\s/?#]+/functions/v[0-9]{1}/.*$'
|
|
)
|
|
|
|
return regexValidLocalEdgeFunctionURL.test(url)
|
|
}
|
|
|
|
const regexValidEdgeFunctionURL = new RegExp(
|
|
'^https://[a-z]*.supabase.(red|co)/functions/v[0-9]{1}/.*$'
|
|
)
|
|
|
|
return regexValidEdgeFunctionURL.test(url)
|
|
}
|