@vercel/next 3.2.9 → 3.2.11

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/index.js CHANGED
@@ -42986,6 +42986,8 @@ function convertRedirects(redirects, defaultStatus = 308) {
42986
42986
  return redirects.map(r => {
42987
42987
  const { src, segments } = sourceToRegex(r.source);
42988
42988
  const hasSegments = collectHasSegments(r.has);
42989
+ normalizeHasKeys(r.has);
42990
+ normalizeHasKeys(r.missing);
42989
42991
  try {
42990
42992
  const loc = replaceSegments(segments, hasSegments, r.destination, true);
42991
42993
  let status;
@@ -43006,6 +43008,9 @@ function convertRedirects(redirects, defaultStatus = 308) {
43006
43008
  if (r.has) {
43007
43009
  route.has = r.has;
43008
43010
  }
43011
+ if (r.missing) {
43012
+ route.missing = r.missing;
43013
+ }
43009
43014
  return route;
43010
43015
  }
43011
43016
  catch (e) {
@@ -43018,12 +43023,17 @@ function convertRewrites(rewrites, internalParamNames) {
43018
43023
  return rewrites.map(r => {
43019
43024
  const { src, segments } = sourceToRegex(r.source);
43020
43025
  const hasSegments = collectHasSegments(r.has);
43026
+ normalizeHasKeys(r.has);
43027
+ normalizeHasKeys(r.missing);
43021
43028
  try {
43022
43029
  const dest = replaceSegments(segments, hasSegments, r.destination, false, internalParamNames);
43023
43030
  const route = { src, dest, check: true };
43024
43031
  if (r.has) {
43025
43032
  route.has = r.has;
43026
43033
  }
43034
+ if (r.missing) {
43035
+ route.missing = r.missing;
43036
+ }
43027
43037
  return route;
43028
43038
  }
43029
43039
  catch (e) {
@@ -43037,6 +43047,8 @@ function convertHeaders(headers) {
43037
43047
  const obj = {};
43038
43048
  const { src, segments } = sourceToRegex(h.source);
43039
43049
  const hasSegments = collectHasSegments(h.has);
43050
+ normalizeHasKeys(h.has);
43051
+ normalizeHasKeys(h.missing);
43040
43052
  const namedSegments = segments.filter(name => name !== UN_NAMED_SEGMENT);
43041
43053
  const indexes = {};
43042
43054
  segments.forEach((name, index) => {
@@ -43064,6 +43076,9 @@ function convertHeaders(headers) {
43064
43076
  if (h.has) {
43065
43077
  route.has = h.has;
43066
43078
  }
43079
+ if (h.missing) {
43080
+ route.missing = h.missing;
43081
+ }
43067
43082
  return route;
43068
43083
  });
43069
43084
  }
@@ -43114,12 +43129,17 @@ function sourceToRegex(source) {
43114
43129
  }
43115
43130
  exports.sourceToRegex = sourceToRegex;
43116
43131
  const namedGroupsRegex = /\(\?<([a-zA-Z][a-zA-Z0-9]*)>/g;
43117
- function collectHasSegments(has) {
43118
- const hasSegments = new Set();
43119
- for (const hasItem of has || []) {
43132
+ const normalizeHasKeys = (hasItems = []) => {
43133
+ for (const hasItem of hasItems) {
43120
43134
  if ('key' in hasItem && hasItem.type === 'header') {
43121
43135
  hasItem.key = hasItem.key.toLowerCase();
43122
43136
  }
43137
+ }
43138
+ return hasItems;
43139
+ };
43140
+ function collectHasSegments(has) {
43141
+ const hasSegments = new Set();
43142
+ for (const hasItem of has || []) {
43123
43143
  if (!hasItem.value && 'key' in hasItem) {
43124
43144
  hasSegments.add(hasItem.key);
43125
43145
  }
@@ -46375,7 +46395,21 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
46375
46395
  }
46376
46396
  }
46377
46397
  }
46378
- const rscHeader = routesManifest.rsc?.header || '__rsc__';
46398
+ const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
46399
+ const completeDynamicRoutes = [];
46400
+ if (appDir) {
46401
+ for (const route of dynamicRoutes) {
46402
+ completeDynamicRoutes.push(route);
46403
+ completeDynamicRoutes.push({
46404
+ ...route,
46405
+ src: route.src.replace(new RegExp((0, escape_string_regexp_1.default)('(?:/)?$')), '(?:\\.rsc)?(?:/)?$'),
46406
+ dest: route.dest?.replace(/($|\?)/, '.rsc$1'),
46407
+ });
46408
+ }
46409
+ }
46410
+ else {
46411
+ completeDynamicRoutes.push(...dynamicRoutes);
46412
+ }
46379
46413
  return {
46380
46414
  wildcard: wildcardConfig,
46381
46415
  images: imagesManifest?.images?.loader === 'default'
@@ -46507,7 +46541,13 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
46507
46541
  ...redirects,
46508
46542
  // middleware comes directly after redirects but before
46509
46543
  // beforeFiles rewrites as middleware is not a "file" route
46544
+ ...(routesManifest?.skipMiddlewareUrlNormalize
46545
+ ? denormalizeNextDataRoute(true)
46546
+ : []),
46510
46547
  ...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
46548
+ ...(routesManifest?.skipMiddlewareUrlNormalize
46549
+ ? normalizeNextDataRoute(true)
46550
+ : []),
46511
46551
  ...beforeFilesRewrites,
46512
46552
  // Make sure to 404 for the /404 path itself
46513
46553
  ...(i18n
@@ -46666,7 +46706,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
46666
46706
  ? // when resolving data routes for middleware we need to include
46667
46707
  // all dynamic routes including non-SSG/SSP so that the priority
46668
46708
  // is correct
46669
- dynamicRoutes
46709
+ completeDynamicRoutes
46670
46710
  .map(route => {
46671
46711
  route = Object.assign({}, route);
46672
46712
  let normalizedSrc = route.src;
@@ -46712,7 +46752,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
46712
46752
  : []),
46713
46753
  // Dynamic routes (must come after dataRoutes as dataRoutes are more
46714
46754
  // specific)
46715
- ...dynamicRoutes,
46755
+ ...completeDynamicRoutes,
46716
46756
  ...(isNextDataServerResolving
46717
46757
  ? [
46718
46758
  {
@@ -48482,6 +48522,7 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
48482
48522
  key: 'x-prerender-revalidate',
48483
48523
  value: prerenderBypassToken,
48484
48524
  },
48525
+ ...(matcher.missing || []),
48485
48526
  ],
48486
48527
  };
48487
48528
  route.middlewarePath = shortPath;
@@ -48581,6 +48622,9 @@ function getRouteMatchers(info, { basePath = '', i18n }) {
48581
48622
  if (matcher.has) {
48582
48623
  m.has = normalizeHas(matcher.has);
48583
48624
  }
48625
+ if (matcher.missing) {
48626
+ m.missing = normalizeHas(matcher.missing);
48627
+ }
48584
48628
  return m;
48585
48629
  });
48586
48630
  }
@@ -663,7 +663,21 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
663
663
  }
664
664
  }
665
665
  }
666
- const rscHeader = routesManifest.rsc?.header || '__rsc__';
666
+ const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
667
+ const completeDynamicRoutes = [];
668
+ if (appDir) {
669
+ for (const route of dynamicRoutes) {
670
+ completeDynamicRoutes.push(route);
671
+ completeDynamicRoutes.push({
672
+ ...route,
673
+ src: route.src.replace(new RegExp((0, escape_string_regexp_1.default)('(?:/)?$')), '(?:\\.rsc)?(?:/)?$'),
674
+ dest: route.dest?.replace(/($|\?)/, '.rsc$1'),
675
+ });
676
+ }
677
+ }
678
+ else {
679
+ completeDynamicRoutes.push(...dynamicRoutes);
680
+ }
667
681
  return {
668
682
  wildcard: wildcardConfig,
669
683
  images: imagesManifest?.images?.loader === 'default'
@@ -795,7 +809,13 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
795
809
  ...redirects,
796
810
  // middleware comes directly after redirects but before
797
811
  // beforeFiles rewrites as middleware is not a "file" route
812
+ ...(routesManifest?.skipMiddlewareUrlNormalize
813
+ ? denormalizeNextDataRoute(true)
814
+ : []),
798
815
  ...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
816
+ ...(routesManifest?.skipMiddlewareUrlNormalize
817
+ ? normalizeNextDataRoute(true)
818
+ : []),
799
819
  ...beforeFilesRewrites,
800
820
  // Make sure to 404 for the /404 path itself
801
821
  ...(i18n
@@ -954,7 +974,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
954
974
  ? // when resolving data routes for middleware we need to include
955
975
  // all dynamic routes including non-SSG/SSP so that the priority
956
976
  // is correct
957
- dynamicRoutes
977
+ completeDynamicRoutes
958
978
  .map(route => {
959
979
  route = Object.assign({}, route);
960
980
  let normalizedSrc = route.src;
@@ -1000,7 +1020,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
1000
1020
  : []),
1001
1021
  // Dynamic routes (must come after dataRoutes as dataRoutes are more
1002
1022
  // specific)
1003
- ...dynamicRoutes,
1023
+ ...completeDynamicRoutes,
1004
1024
  ...(isNextDataServerResolving
1005
1025
  ? [
1006
1026
  {
package/dist/utils.js CHANGED
@@ -1549,6 +1549,7 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1549
1549
  key: 'x-prerender-revalidate',
1550
1550
  value: prerenderBypassToken,
1551
1551
  },
1552
+ ...(matcher.missing || []),
1552
1553
  ],
1553
1554
  };
1554
1555
  route.middlewarePath = shortPath;
@@ -1648,6 +1649,9 @@ function getRouteMatchers(info, { basePath = '', i18n }) {
1648
1649
  if (matcher.has) {
1649
1650
  m.has = normalizeHas(matcher.has);
1650
1651
  }
1652
+ if (matcher.missing) {
1653
+ m.missing = normalizeHas(matcher.missing);
1654
+ }
1651
1655
  return m;
1652
1656
  });
1653
1657
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.2.9",
3
+ "version": "3.2.11",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -46,7 +46,7 @@
46
46
  "@types/webpack-sources": "3.2.0",
47
47
  "@vercel/build-utils": "5.5.7",
48
48
  "@vercel/nft": "0.22.1",
49
- "@vercel/routing-utils": "2.1.2",
49
+ "@vercel/routing-utils": "2.1.3",
50
50
  "async-sema": "3.0.1",
51
51
  "buffer-crc32": "0.2.13",
52
52
  "cheerio": "1.0.0-rc.10",
@@ -69,5 +69,5 @@
69
69
  "typescript": "4.5.2",
70
70
  "webpack-sources": "3.2.3"
71
71
  },
72
- "gitHead": "0964be17106419263b3f38d67784dd97b8b0c565"
72
+ "gitHead": "1b211f28dfdcb112f1aecb53a2b9f257ecc58420"
73
73
  }