MCPcopy Create free account
hub / github.com/context-space/context-space / isRouteMatch

Function isRouteMatch

web/src/middleware.ts:22–42  ·  view source on GitHub ↗
(pathname: string, routes: string[])

Source from the content-addressed store, hash-verified

20}
21
22function isRouteMatch(pathname: string, routes: string[]): boolean {
23 return routes.some((route) => {
24 if (route === pathname) {
25 return true
26 }
27
28 if (route.endsWith("**")) {
29 const prefix = route.slice(0, -2)
30
31 return pathname.startsWith(prefix)
32 }
33
34 if (route.endsWith("*")) {
35 const prefix = route.slice(0, -1)
36
37 return pathname.startsWith(prefix) && !pathname.slice(prefix.length).includes("/")
38 }
39
40 return false
41 })
42}
43
44function handleUnauthenticated(request: NextRequest, pathname: string): NextResponse {
45 if (pathname.startsWith("/api/")) {

Callers 1

middlewareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected