( path: string, querySlugs: string[], )
| 104 | } |
| 105 | |
| 106 | export function getPathParameters( |
| 107 | path: string, |
| 108 | querySlugs: string[], |
| 109 | ): { [name: string]: string } { |
| 110 | let variables: { [name: string]: string } = {}; |
| 111 | const urlSlugs = path.split("/").filter((slug) => slug !== ""); |
| 112 | if (urlSlugs.length !== querySlugs.length) |
| 113 | throw new Error( |
| 114 | `Path and query slugs lengths do not match: [${urlSlugs}] AND [${querySlugs}]`, |
| 115 | ); |
| 116 | |
| 117 | for (let index = 0; index < urlSlugs.length; index++) { |
| 118 | // slicing to remove { and } from urlSlugs variable name |
| 119 | if (urlSlugs[index].startsWith("{") && urlSlugs[index].endsWith("}")) { |
| 120 | const variableName = urlSlugs[index].slice(1, urlSlugs[index].length - 1); |
| 121 | variables[variableName] = querySlugs[index]; |
| 122 | } |
| 123 | } |
| 124 | return variables; |
| 125 | } |
| 126 | |
| 127 | const supabase = createClient( |
| 128 | process.env.NEXT_PUBLIC_SUPABASE_URL ?? "", |
no outgoing calls
no test coverage detected