edgeFunctions.ts23 lines · main
| 1 | const NIMBUS_PROD_PROJECTS_URL = process.env.NIMBUS_PROD_PROJECTS_URL |
| 2 | |
| 3 | export const isValidEdgeFunctionURL = (url: string, isPlatform: boolean) => { |
| 4 | if (NIMBUS_PROD_PROJECTS_URL !== undefined) { |
| 5 | const apexDomain = NIMBUS_PROD_PROJECTS_URL.replace('https://*.', '').replace(/\./g, '\\.') |
| 6 | const nimbusRegex = new RegExp('^https://[a-z]*\\.' + apexDomain + '/functions/v[0-9]{1}/.*$') |
| 7 | return nimbusRegex.test(url) |
| 8 | } |
| 9 | |
| 10 | if (!isPlatform) { |
| 11 | const regexValidLocalEdgeFunctionURL = new RegExp( |
| 12 | /^https?:\/\/[^\s/?#]+\/functions\/v[0-9]{1}\/.*$/ |
| 13 | ) |
| 14 | |
| 15 | return regexValidLocalEdgeFunctionURL.test(url) |
| 16 | } |
| 17 | |
| 18 | const regexValidEdgeFunctionURL = new RegExp( |
| 19 | /^https:\/\/[a-z]{20}\.briven\.(red|co)\/functions\/v[0-9]{1}\/.*$/ |
| 20 | ) |
| 21 | |
| 22 | return regexValidEdgeFunctionURL.test(url) |
| 23 | } |