MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / getPathParameters

Function getPathParameters

pages/api/mock/[...slug].ts:106–125  ·  view source on GitHub ↗
(
  path: string,
  querySlugs: string[],
)

Source from the content-addressed store, hash-verified

104}
105
106export 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
127const supabase = createClient(
128 process.env.NEXT_PUBLIC_SUPABASE_URL ?? "",

Callers 2

slug.test.tsFile · 0.90
handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected