@vercel/next 12.0.3 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/node-handler.js +20 -2
- package/dist/index.js +1288 -232
- package/package.json +6 -4
|
@@ -167,7 +167,8 @@ const getHandlerSource = (ctx) => `
|
|
|
167
167
|
return {
|
|
168
168
|
matchedPathname: inversedAppRoutesManifest[route.page] || route.page,
|
|
169
169
|
locale: normalizeResult.locale,
|
|
170
|
-
matches
|
|
170
|
+
matches,
|
|
171
|
+
matchedRoute: route
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
}
|
|
@@ -236,6 +237,15 @@ const getHandlerSource = (ctx) => `
|
|
|
236
237
|
const decoder = new TextDecoder("utf-8");
|
|
237
238
|
return decoder.decode(bytes);
|
|
238
239
|
}
|
|
240
|
+
function isOptionalCatchallTemplateCapture(matchedRoute, matchKey, matchValue) {
|
|
241
|
+
if (!matchedRoute) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
const prefixedParamName = matchedRoute.routeKeys?.[matchKey] ?? matchKey;
|
|
245
|
+
const paramName = prefixedParamName.startsWith("nxtP") ? prefixedParamName.slice(4) : prefixedParamName;
|
|
246
|
+
const placeholder = `[[...${paramName}]]`;
|
|
247
|
+
return matchValue === placeholder && matchedRoute.page.split("/").includes(placeholder);
|
|
248
|
+
}
|
|
239
249
|
return async function handler(req, res, internalMetadata) {
|
|
240
250
|
try {
|
|
241
251
|
const parsedUrl = new URL(req.url || "/", "http://n");
|
|
@@ -247,13 +257,21 @@ const getHandlerSource = (ctx) => `
|
|
|
247
257
|
const {
|
|
248
258
|
matchedPathname: page,
|
|
249
259
|
locale,
|
|
250
|
-
matches
|
|
260
|
+
matches,
|
|
261
|
+
matchedRoute
|
|
251
262
|
} = matchUrlToPage(urlPathname);
|
|
252
263
|
const isAppDir = page.match(/\/(page|route)$/);
|
|
253
264
|
let addedMatchesToUrl = false;
|
|
254
265
|
for (const matchKey in matches?.groups || {}) {
|
|
255
266
|
const matchValue = matches?.groups?.[matchKey];
|
|
256
267
|
if (!parsedUrl.searchParams.has(matchKey) && matchValue) {
|
|
268
|
+
if (isOptionalCatchallTemplateCapture(
|
|
269
|
+
matchedRoute,
|
|
270
|
+
matchKey,
|
|
271
|
+
matchValue
|
|
272
|
+
)) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
257
275
|
parsedUrl.searchParams.set(matchKey, matchValue);
|
|
258
276
|
addedMatchesToUrl = true;
|
|
259
277
|
}
|