Files
supabase/apps/studio/lib/api/edgeFunctions.ts
Etienne Stalmans b79a645f4f fix: escape regex control character (#43806)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES
## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

regex control character, `.` is not escaped.

## What is the new behavior?

Escapes control characters and makes regex a little stricter. Use regex
literal
2026-03-17 16:28:38 +01:00

24 lines
801 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]{20}\.supabase\.(red|co)\/functions\/v[0-9]{1}\/.*$/
)
return regexValidEdgeFunctionURL.test(url)
}