mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 17:30:25 -04:00
b79a645f4f
## 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
24 lines
801 B
TypeScript
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)
|
|
}
|