vinext 0.0.12 → 0.0.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"app-dev-server.d.ts","sourceRoot":"","sources":["../../src/server/app-dev-server.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,WAAW,EAAE,WAAW,EAAE,CAAC;QAC3B,UAAU,EAAE,WAAW,EAAE,CAAC;QAC1B,QAAQ,EAAE,WAAW,EAAE,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,4GAA4G;IAC5G,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,uGAAuG;IACvG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,EAAE,EAClB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,EAC9B,cAAc,CAAC,EAAE,iBAAiB,EAAE,EACpC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,EAC/B,QAAQ,CAAC,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,MAAM,CAAC,EAAE,eAAe,GACvB,MAAM,CAumER;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CA6XzC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA2S7C"}
1
+ {"version":3,"file":"app-dev-server.d.ts","sourceRoot":"","sources":["../../src/server/app-dev-server.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,WAAW,EAAE,WAAW,EAAE,CAAC;QAC3B,UAAU,EAAE,WAAW,EAAE,CAAC;QAC1B,QAAQ,EAAE,WAAW,EAAE,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,4GAA4G;IAC5G,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,uGAAuG;IACvG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,EAAE,EAClB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,EAC9B,cAAc,CAAC,EAAE,iBAAiB,EAAE,EACpC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,EAC/B,QAAQ,CAAC,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,MAAM,CAAC,EAAE,eAAe,GACvB,MAAM,CA4mER;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CA6XzC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA2S7C"}
@@ -516,7 +516,9 @@ async function renderErrorBoundaryPage(route, error, isRscRequest, request) {
516
516
  function matchRoute(url, routes) {
517
517
  const pathname = url.split("?")[0];
518
518
  let normalizedUrl = pathname === "/" ? "/" : pathname.replace(/\\/$/, "");
519
- try { normalizedUrl = decodeURIComponent(normalizedUrl); } catch {}
519
+ // NOTE: Do NOT decodeURIComponent here. The caller is responsible for decoding
520
+ // the pathname exactly once at the request entry point. Decoding again here
521
+ // would cause inconsistent path matching between middleware and routing.
520
522
  for (const route of routes) {
521
523
  const params = matchPattern(normalizedUrl, route.pattern);
522
524
  if (params !== null) return { route, params };
@@ -922,7 +924,8 @@ function __matchConfigPattern(pathname, pattern) {
922
924
  const rest = pathname.slice(prefix.replace(/\\/$/, "").length);
923
925
  if (isPlus && (!rest || rest === "/")) return null;
924
926
  let restValue = rest.startsWith("/") ? rest.slice(1) : rest;
925
- try { restValue = decodeURIComponent(restValue); } catch {}
927
+ // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at
928
+ // the request entry point. Decoding again would produce incorrect param values.
926
929
  return { [paramName]: restValue };
927
930
  }
928
931
  const parts = pattern.split("/");
@@ -1170,7 +1173,8 @@ export default async function handler(request) {
1170
1173
  // and Next.js doesn't apply custom headers to redirects anyway.
1171
1174
  if (__configHeaders.length && response && response.headers && !(response.status >= 300 && response.status < 400)) {
1172
1175
  const url = new URL(request.url);
1173
- let pathname = url.pathname;
1176
+ let pathname;
1177
+ try { pathname = __normalizePath(decodeURIComponent(url.pathname)); } catch { pathname = url.pathname; }
1174
1178
  ${bp ? `if (pathname.startsWith(${JSON.stringify(bp)})) pathname = pathname.slice(${JSON.stringify(bp)}.length) || "/";` : ""}
1175
1179
  const extraHeaders = __applyConfigHeaders(pathname);
1176
1180
  for (const h of extraHeaders) {
@@ -1269,26 +1273,27 @@ async function _handleRequest(request) {
1269
1273
  let _middlewareRewriteStatus = null;
1270
1274
 
1271
1275
  ${middlewarePath ? `
1272
- // Run proxy/middleware if present and path matches
1276
+ // Run proxy/middleware if present and path matches
1273
1277
  const middlewareFn = middlewareModule.default || middlewareModule.proxy || middlewareModule.middleware;
1274
1278
  const middlewareMatcher = middlewareModule.config?.matcher;
1275
1279
  if (typeof middlewareFn === "function" && matchesMiddleware(cleanPathname, middlewareMatcher)) {
1276
1280
  try {
1277
1281
  // Wrap in NextRequest so middleware gets .nextUrl, .cookies, .geo, .ip, etc.
1278
- // Strip .rsc suffix from the URL it's an internal transport detail that
1279
- // middleware should never see (matches Next.js behavior).
1280
- let mwRequest = request;
1281
- if (isRscRequest && pathname.endsWith(".rsc")) {
1282
- const mwUrl = new URL(request.url);
1283
- mwUrl.pathname = cleanPathname;
1284
- mwRequest = new Request(mwUrl, request);
1285
- }
1282
+ // Always construct a new Request with the fully decoded + normalized pathname
1283
+ // so middleware and the router see the same canonical path.
1284
+ const mwUrl = new URL(request.url);
1285
+ mwUrl.pathname = cleanPathname;
1286
+ const mwRequest = new Request(mwUrl, request);
1286
1287
  const nextRequest = mwRequest instanceof NextRequest ? mwRequest : new NextRequest(mwRequest);
1287
1288
  const mwResponse = await middlewareFn(nextRequest);
1288
1289
  if (mwResponse) {
1289
1290
  // Check for x-middleware-next (continue)
1290
1291
  if (mwResponse.headers.get("x-middleware-next") === "1") {
1291
- // Middleware wants to continue - save headers to merge into final response
1292
+ // Middleware wants to continue collect all headers except the two
1293
+ // control headers we've already consumed. x-middleware-request-*
1294
+ // headers are kept so applyMiddlewareRequestHeaders() can unpack them;
1295
+ // the blanket strip loop after that call removes every remaining
1296
+ // x-middleware-* header before the set is merged into the response.
1292
1297
  _middlewareResponseHeaders = new Headers();
1293
1298
  for (const [key, value] of mwResponse.headers) {
1294
1299
  if (key !== "x-middleware-next" && key !== "x-middleware-rewrite") {