Skip to content

Commit 52dd955

Browse files
committed
TMP: Leave only negation part in vercel middleware matcher
1 parent 7cab01e commit 52dd955

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

integrations/vercel-middleware/utils/matcher.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ export function buildMiddlewareMatcherRegexp(routes: IntegrationResolvedRoute[])
44
const groupedRoutes = Object.groupBy(routes, (r) => r.origin);
55
const dontMatchPatterns =
66
groupedRoutes.internal?.map((r) => stripPatternRegexp(r.patternRegex)) ?? [];
7-
const matchPatterns = groupedRoutes.project?.map((r) => stripPatternRegexp(r.patternRegex)) ?? [];
87

9-
// The regex is constructed to first negate any paths that match the internal patterns
10-
// and then allow paths that match the project patterns.
11-
// For example it can output such regexp: /^(?!.*\/(_server-islands\/[^\/]+\/?|_image\/?)$)(?:\/(.*?))?\/?)$/;
12-
return `^(?!.*(${dontMatchPatterns.join("|")})$)(?:${matchPatterns.join("|")})$`;
8+
// The regex is constructed to negate any internal Astro paths
9+
// For example it can output such regexp: /^(?!.*\/(_server-islands\/[^\/]+\/?|_image\/?)$).*$/;
10+
return `^(?!.*(${dontMatchPatterns.join("|")})$).*$`;
1311
}
1412

1513
const PATTERN_STRIP_LINE_START = /^\^/;

0 commit comments

Comments
 (0)