Files
supabase/apps/studio/lib/api/edgeFunctions.ts
T
Kalleby SantosandCharis Lam 70510acf5b feat(studio-local): functions management api - test functions (#42350)
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>
2026-02-11 21:26:42 +00:00

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)
}