@vercel/redwood 2.5.0 → 2.5.2
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 +276 -33
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -266,7 +266,7 @@ var require_dist = __commonJS({
|
|
|
266
266
|
exports.tokensToFunction = tokensToFunction;
|
|
267
267
|
function match(str, options) {
|
|
268
268
|
var keys = [];
|
|
269
|
-
var re =
|
|
269
|
+
var re = pathToRegexp2(str, keys, options);
|
|
270
270
|
return regexpToFunction(re, keys, options);
|
|
271
271
|
}
|
|
272
272
|
exports.match = match;
|
|
@@ -327,7 +327,7 @@ var require_dist = __commonJS({
|
|
|
327
327
|
}
|
|
328
328
|
function arrayToRegexp(paths, keys, options) {
|
|
329
329
|
var parts = paths.map(function(path) {
|
|
330
|
-
return
|
|
330
|
+
return pathToRegexp2(path, keys, options).source;
|
|
331
331
|
});
|
|
332
332
|
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
|
|
333
333
|
}
|
|
@@ -389,14 +389,14 @@ var require_dist = __commonJS({
|
|
|
389
389
|
return new RegExp(route, flags(options));
|
|
390
390
|
}
|
|
391
391
|
exports.tokensToRegexp = tokensToRegexp;
|
|
392
|
-
function
|
|
392
|
+
function pathToRegexp2(path, keys, options) {
|
|
393
393
|
if (path instanceof RegExp)
|
|
394
394
|
return regexpToRegexp(path, keys);
|
|
395
395
|
if (Array.isArray(path))
|
|
396
396
|
return arrayToRegexp(path, keys, options);
|
|
397
397
|
return stringToRegexp(path, keys, options);
|
|
398
398
|
}
|
|
399
|
-
exports.pathToRegexp =
|
|
399
|
+
exports.pathToRegexp = pathToRegexp2;
|
|
400
400
|
}
|
|
401
401
|
});
|
|
402
402
|
|
|
@@ -654,7 +654,7 @@ var require_dist2 = __commonJS({
|
|
|
654
654
|
exports.tokensToFunction = tokensToFunction;
|
|
655
655
|
function match(str, options) {
|
|
656
656
|
var keys = [];
|
|
657
|
-
var re =
|
|
657
|
+
var re = pathToRegexp2(str, keys, options);
|
|
658
658
|
return regexpToFunction(re, keys, options);
|
|
659
659
|
}
|
|
660
660
|
exports.match = match;
|
|
@@ -717,7 +717,7 @@ var require_dist2 = __commonJS({
|
|
|
717
717
|
}
|
|
718
718
|
function arrayToRegexp(paths, keys, options) {
|
|
719
719
|
var parts = paths.map(function(path) {
|
|
720
|
-
return
|
|
720
|
+
return pathToRegexp2(path, keys, options).source;
|
|
721
721
|
});
|
|
722
722
|
return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
|
|
723
723
|
}
|
|
@@ -779,14 +779,14 @@ var require_dist2 = __commonJS({
|
|
|
779
779
|
return new RegExp(route, flags(options));
|
|
780
780
|
}
|
|
781
781
|
exports.tokensToRegexp = tokensToRegexp;
|
|
782
|
-
function
|
|
782
|
+
function pathToRegexp2(path, keys, options) {
|
|
783
783
|
if (path instanceof RegExp)
|
|
784
784
|
return regexpToRegexp(path, keys);
|
|
785
785
|
if (Array.isArray(path))
|
|
786
786
|
return arrayToRegexp(path, keys, options);
|
|
787
787
|
return stringToRegexp(path, keys, options);
|
|
788
788
|
}
|
|
789
|
-
exports.pathToRegexp =
|
|
789
|
+
exports.pathToRegexp = pathToRegexp2;
|
|
790
790
|
}
|
|
791
791
|
});
|
|
792
792
|
|
|
@@ -814,13 +814,14 @@ var require_superstatic = __commonJS({
|
|
|
814
814
|
var superstatic_exports = {};
|
|
815
815
|
__export2(superstatic_exports, {
|
|
816
816
|
collectHasSegments: () => collectHasSegments,
|
|
817
|
+
compilePathToRegexpTemplate: () => compilePathToRegexpTemplate2,
|
|
817
818
|
convertCleanUrls: () => convertCleanUrls,
|
|
818
819
|
convertHeaders: () => convertHeaders,
|
|
819
820
|
convertRedirects: () => convertRedirects,
|
|
820
|
-
convertRewrites: () =>
|
|
821
|
+
convertRewrites: () => convertRewrites2,
|
|
821
822
|
convertTrailingSlash: () => convertTrailingSlash,
|
|
822
823
|
getCleanUrls: () => getCleanUrls2,
|
|
823
|
-
pathToRegexp: () =>
|
|
824
|
+
pathToRegexp: () => pathToRegexp2,
|
|
824
825
|
sourceToRegex: () => sourceToRegex2
|
|
825
826
|
});
|
|
826
827
|
module2.exports = __toCommonJS2(superstatic_exports);
|
|
@@ -838,7 +839,7 @@ var require_superstatic = __commonJS({
|
|
|
838
839
|
const rightSerialized = typeof right === "undefined" ? "undefined" : right.toString();
|
|
839
840
|
return leftSerialized === rightSerialized;
|
|
840
841
|
}
|
|
841
|
-
function
|
|
842
|
+
function pathToRegexp2(callerId, path, keys, options) {
|
|
842
843
|
const newKeys = cloneKeys(keys);
|
|
843
844
|
const currentRegExp = (0, import_path_to_regexp.pathToRegexp)(path, keys, options);
|
|
844
845
|
try {
|
|
@@ -933,21 +934,46 @@ var require_superstatic = __commonJS({
|
|
|
933
934
|
}
|
|
934
935
|
});
|
|
935
936
|
}
|
|
936
|
-
function
|
|
937
|
+
function convertRewrites2(rewrites, internalParamNames) {
|
|
937
938
|
return rewrites.map((r) => {
|
|
938
939
|
const { src, segments } = sourceToRegex2(r.source);
|
|
939
940
|
const hasSegments = collectHasSegments(r.has);
|
|
940
941
|
normalizeHasKeys(r.has);
|
|
941
942
|
normalizeHasKeys(r.missing);
|
|
942
943
|
try {
|
|
943
|
-
const
|
|
944
|
+
const interpolate = (value) => replaceSegments(
|
|
944
945
|
segments,
|
|
945
946
|
hasSegments,
|
|
946
|
-
|
|
947
|
+
value,
|
|
947
948
|
false,
|
|
948
949
|
internalParamNames
|
|
949
950
|
);
|
|
950
|
-
|
|
951
|
+
let route;
|
|
952
|
+
if (typeof r.destination === "string") {
|
|
953
|
+
route = { src, dest: interpolate(r.destination), check: true };
|
|
954
|
+
} else {
|
|
955
|
+
const destination = { ...r.destination, type: "service" };
|
|
956
|
+
if (typeof destination.path === "string") {
|
|
957
|
+
destination.path = interpolate(destination.path);
|
|
958
|
+
}
|
|
959
|
+
route = { src, destination };
|
|
960
|
+
}
|
|
961
|
+
if (r.transforms) {
|
|
962
|
+
route.transforms = r.transforms.map((transform) => {
|
|
963
|
+
if (transform.type !== "request.path") {
|
|
964
|
+
return { ...transform };
|
|
965
|
+
}
|
|
966
|
+
return {
|
|
967
|
+
...transform,
|
|
968
|
+
args: compilePathToRegexpTemplateFromSegments(
|
|
969
|
+
transform.args,
|
|
970
|
+
segments,
|
|
971
|
+
hasSegments,
|
|
972
|
+
transform.env
|
|
973
|
+
)
|
|
974
|
+
};
|
|
975
|
+
});
|
|
976
|
+
}
|
|
951
977
|
if (typeof r.env !== "undefined") {
|
|
952
978
|
route.env = r.env;
|
|
953
979
|
}
|
|
@@ -1033,7 +1059,7 @@ var require_superstatic = __commonJS({
|
|
|
1033
1059
|
}
|
|
1034
1060
|
function sourceToRegex2(source) {
|
|
1035
1061
|
const keys = [];
|
|
1036
|
-
const r =
|
|
1062
|
+
const r = pathToRegexp2("632", source, keys, {
|
|
1037
1063
|
strict: true,
|
|
1038
1064
|
sensitive: true,
|
|
1039
1065
|
delimiter: "/"
|
|
@@ -1088,6 +1114,81 @@ var require_superstatic = __commonJS({
|
|
|
1088
1114
|
}
|
|
1089
1115
|
var escapeSegment = (str, segmentName) => str.replace(new RegExp(`:${segmentName}`, "g"), `__ESC_COLON_${segmentName}`);
|
|
1090
1116
|
var unescapeSegments = (str) => str.replace(/__ESC_COLON_/gi, ":");
|
|
1117
|
+
var pathTemplateSegmentNameRegex = /^([a-zA-Z_][a-zA-Z0-9_]*)/;
|
|
1118
|
+
function isEscaped(value, index) {
|
|
1119
|
+
let backslashCount = 0;
|
|
1120
|
+
for (let i = index - 1; i >= 0 && value[i] === "\\"; i--) {
|
|
1121
|
+
backslashCount++;
|
|
1122
|
+
}
|
|
1123
|
+
return backslashCount % 2 === 1;
|
|
1124
|
+
}
|
|
1125
|
+
function collectPathTemplateSegments(template) {
|
|
1126
|
+
const segments = [];
|
|
1127
|
+
for (let i = 0; i < template.length; i++) {
|
|
1128
|
+
if (template[i] !== ":" || isEscaped(template, i)) {
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
const match = template.slice(i + 1).match(pathTemplateSegmentNameRegex);
|
|
1132
|
+
if (match) {
|
|
1133
|
+
segments.push(match[1]);
|
|
1134
|
+
i += match[1].length;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return segments;
|
|
1138
|
+
}
|
|
1139
|
+
function collectNamedDollarReferences(template) {
|
|
1140
|
+
const references = [];
|
|
1141
|
+
for (let i = 0; i < template.length; i++) {
|
|
1142
|
+
if (template[i] !== "$" || isEscaped(template, i)) {
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
const remainder = template.slice(i + 1);
|
|
1146
|
+
const bracedMatch = remainder.match(/^\{([a-zA-Z_][a-zA-Z0-9_]*)\}/);
|
|
1147
|
+
const unbracedMatch = remainder.match(pathTemplateSegmentNameRegex);
|
|
1148
|
+
const name = bracedMatch?.[1] || unbracedMatch?.[1];
|
|
1149
|
+
if (name) {
|
|
1150
|
+
references.push(name);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
return references;
|
|
1154
|
+
}
|
|
1155
|
+
function compilePathToRegexpTemplateFromSegments(template, segments, hasItemSegments, env = []) {
|
|
1156
|
+
const indexes = {};
|
|
1157
|
+
segments.forEach((name, index) => {
|
|
1158
|
+
indexes[name] = toSegmentDest(index);
|
|
1159
|
+
});
|
|
1160
|
+
hasItemSegments.forEach((name) => {
|
|
1161
|
+
indexes[name] = `$${name}`;
|
|
1162
|
+
});
|
|
1163
|
+
for (const name of collectPathTemplateSegments(template)) {
|
|
1164
|
+
if (!(name in indexes)) {
|
|
1165
|
+
throw new Error(
|
|
1166
|
+
`Path template references parameter ":${name}" that is not present in the source or has conditions.`
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
const routeParameters = /* @__PURE__ */ new Set([
|
|
1171
|
+
...segments.filter((name) => name !== UN_NAMED_SEGMENT),
|
|
1172
|
+
...hasItemSegments
|
|
1173
|
+
]);
|
|
1174
|
+
for (const name of collectNamedDollarReferences(template)) {
|
|
1175
|
+
if (routeParameters.has(name) && !env.includes(name)) {
|
|
1176
|
+
throw new Error(
|
|
1177
|
+
`Path template references route parameter "${name}" as \`$${name}\`. Use \`:${name}\` path-to-regexp syntax in high-level rewrites, or list "${name}" in the transform env allowlist if it is an environment variable.`
|
|
1178
|
+
);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
return safelyCompile(template, indexes, true);
|
|
1182
|
+
}
|
|
1183
|
+
function compilePathToRegexpTemplate2(source, template, has, env) {
|
|
1184
|
+
const { segments } = sourceToRegex2(source);
|
|
1185
|
+
return compilePathToRegexpTemplateFromSegments(
|
|
1186
|
+
template,
|
|
1187
|
+
segments,
|
|
1188
|
+
collectHasSegments(has),
|
|
1189
|
+
env
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1091
1192
|
function replaceSegments(segments, hasItemSegments, destination, isRedirect, internalParamNames) {
|
|
1092
1193
|
const namedSegments = segments.filter((name) => name !== UN_NAMED_SEGMENT);
|
|
1093
1194
|
const canNeedReplacing = destination.includes(":") && namedSegments.length > 0 || hasItemSegments.length > 0 || !isRedirect;
|
|
@@ -1118,9 +1219,9 @@ var require_superstatic = __commonJS({
|
|
|
1118
1219
|
const hashKeys = [];
|
|
1119
1220
|
const hostnameKeys = [];
|
|
1120
1221
|
try {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1222
|
+
pathToRegexp2("528", pathname, pathnameKeys);
|
|
1223
|
+
pathToRegexp2("834", hash || "", hashKeys);
|
|
1224
|
+
pathToRegexp2("712", hostname || "", hostnameKeys);
|
|
1124
1225
|
} catch (_) {
|
|
1125
1226
|
}
|
|
1126
1227
|
destParams = new Set(
|
|
@@ -1489,7 +1590,8 @@ var require_schemas = __commonJS({
|
|
|
1489
1590
|
redirectsSchema: () => redirectsSchema,
|
|
1490
1591
|
rewritesSchema: () => rewritesSchema,
|
|
1491
1592
|
routesSchema: () => routesSchema,
|
|
1492
|
-
trailingSlashSchema: () => trailingSlashSchema
|
|
1593
|
+
trailingSlashSchema: () => trailingSlashSchema,
|
|
1594
|
+
transformsSchema: () => transformsSchema
|
|
1493
1595
|
});
|
|
1494
1596
|
module2.exports = __toCommonJS2(schemas_exports);
|
|
1495
1597
|
var mitigateSchema = {
|
|
@@ -1505,6 +1607,32 @@ var require_schemas = __commonJS({
|
|
|
1505
1607
|
}
|
|
1506
1608
|
}
|
|
1507
1609
|
};
|
|
1610
|
+
var serviceNameSchema = {
|
|
1611
|
+
description: "A service name identifier.",
|
|
1612
|
+
type: "string",
|
|
1613
|
+
minLength: 1,
|
|
1614
|
+
maxLength: 64,
|
|
1615
|
+
pattern: "^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$"
|
|
1616
|
+
};
|
|
1617
|
+
var serviceDestinationSchema = {
|
|
1618
|
+
description: "A service-targeted destination that delegates routing into a named service from `services`. Identified by the presence of `service`.",
|
|
1619
|
+
type: "object",
|
|
1620
|
+
additionalProperties: false,
|
|
1621
|
+
required: ["service"],
|
|
1622
|
+
properties: {
|
|
1623
|
+
type: {
|
|
1624
|
+
description: "Optional explicit format marker. The destination shape is identified by the `service` property, so `type` is no longer required. When present it must be `service`.",
|
|
1625
|
+
type: "string",
|
|
1626
|
+
enum: ["service"]
|
|
1627
|
+
},
|
|
1628
|
+
service: serviceNameSchema,
|
|
1629
|
+
path: {
|
|
1630
|
+
description: "Routing-only path used to select a route inside the target service. It does not mutate the URL observed by user code.",
|
|
1631
|
+
type: "string",
|
|
1632
|
+
maxLength: 4096
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1508
1636
|
var matchableValueSchema = {
|
|
1509
1637
|
description: "A value to match against. Can be a string (regex) or a condition operation object",
|
|
1510
1638
|
anyOf: [
|
|
@@ -1628,18 +1756,23 @@ var require_schemas = __commonJS({
|
|
|
1628
1756
|
}
|
|
1629
1757
|
};
|
|
1630
1758
|
var transformsSchema = {
|
|
1631
|
-
description: "A list of transform rules to adjust
|
|
1759
|
+
description: "A list of transform rules to adjust a request path, request query parameters, or request/response headers",
|
|
1632
1760
|
type: "array",
|
|
1633
1761
|
minItems: 1,
|
|
1634
1762
|
items: {
|
|
1635
1763
|
type: "object",
|
|
1636
1764
|
additionalProperties: false,
|
|
1637
|
-
required: ["type", "op"
|
|
1765
|
+
required: ["type", "op"],
|
|
1638
1766
|
properties: {
|
|
1639
1767
|
type: {
|
|
1640
1768
|
description: "The scope of the transform to apply",
|
|
1641
1769
|
type: "string",
|
|
1642
|
-
enum: [
|
|
1770
|
+
enum: [
|
|
1771
|
+
"request.headers",
|
|
1772
|
+
"request.query",
|
|
1773
|
+
"response.headers",
|
|
1774
|
+
"request.path"
|
|
1775
|
+
]
|
|
1643
1776
|
},
|
|
1644
1777
|
op: {
|
|
1645
1778
|
description: "The operation to perform on the target",
|
|
@@ -1825,10 +1958,90 @@ var require_schemas = __commonJS({
|
|
|
1825
1958
|
}
|
|
1826
1959
|
}
|
|
1827
1960
|
}
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
if: {
|
|
1964
|
+
required: ["type"],
|
|
1965
|
+
properties: {
|
|
1966
|
+
type: {
|
|
1967
|
+
enum: ["request.headers", "request.query", "response.headers"]
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
},
|
|
1971
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
1972
|
+
then: {
|
|
1973
|
+
required: ["target"]
|
|
1974
|
+
}
|
|
1975
|
+
},
|
|
1976
|
+
{
|
|
1977
|
+
if: {
|
|
1978
|
+
required: ["type"],
|
|
1979
|
+
properties: {
|
|
1980
|
+
type: {
|
|
1981
|
+
enum: ["request.path"]
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
},
|
|
1985
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
1986
|
+
then: {
|
|
1987
|
+
required: ["args"],
|
|
1988
|
+
not: {
|
|
1989
|
+
required: ["target"]
|
|
1990
|
+
},
|
|
1991
|
+
properties: {
|
|
1992
|
+
op: {
|
|
1993
|
+
enum: ["set"]
|
|
1994
|
+
},
|
|
1995
|
+
args: {
|
|
1996
|
+
description: "The runtime-visible request path. Must be an origin-form path without query or fragment.",
|
|
1997
|
+
type: "string",
|
|
1998
|
+
maxLength: 2048,
|
|
1999
|
+
pattern: "^/(?!/)(?!.*[?#\\s\\x00-\\x1F\\x7F]).*$"
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
1828
2003
|
}
|
|
1829
2004
|
]
|
|
1830
2005
|
}
|
|
1831
2006
|
};
|
|
2007
|
+
var rewriteTransformsSchema = {
|
|
2008
|
+
description: "A list of request path transforms using path-to-regexp parameters.",
|
|
2009
|
+
type: "array",
|
|
2010
|
+
minItems: 1,
|
|
2011
|
+
items: {
|
|
2012
|
+
type: "object",
|
|
2013
|
+
additionalProperties: false,
|
|
2014
|
+
required: ["type", "op", "args"],
|
|
2015
|
+
properties: {
|
|
2016
|
+
type: {
|
|
2017
|
+
description: "The request path to expose to the target runtime",
|
|
2018
|
+
type: "string",
|
|
2019
|
+
enum: ["request.path"]
|
|
2020
|
+
},
|
|
2021
|
+
op: {
|
|
2022
|
+
description: "Replace the runtime-visible request path",
|
|
2023
|
+
type: "string",
|
|
2024
|
+
enum: ["set"]
|
|
2025
|
+
},
|
|
2026
|
+
args: {
|
|
2027
|
+
description: "An origin-form request path. Route parameters use path-to-regexp syntax such as `/:path*`.",
|
|
2028
|
+
type: "string",
|
|
2029
|
+
maxLength: 2048,
|
|
2030
|
+
pattern: "^/(?!/)(?!.*[?#\\s\\x00-\\x1F\\x7F]).*$"
|
|
2031
|
+
},
|
|
2032
|
+
env: {
|
|
2033
|
+
description: "An array of environment variable names that should be replaced at runtime in the args value",
|
|
2034
|
+
type: "array",
|
|
2035
|
+
minItems: 1,
|
|
2036
|
+
maxItems: 64,
|
|
2037
|
+
items: {
|
|
2038
|
+
type: "string",
|
|
2039
|
+
maxLength: 256
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
};
|
|
1832
2045
|
var routesSchema = {
|
|
1833
2046
|
type: "array",
|
|
1834
2047
|
description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
|
|
@@ -1853,8 +2066,10 @@ var require_schemas = __commonJS({
|
|
|
1853
2066
|
maxLength: 4096
|
|
1854
2067
|
},
|
|
1855
2068
|
destination: {
|
|
1856
|
-
|
|
1857
|
-
|
|
2069
|
+
anyOf: [
|
|
2070
|
+
{ type: "string", maxLength: 4096 },
|
|
2071
|
+
serviceDestinationSchema
|
|
2072
|
+
]
|
|
1858
2073
|
},
|
|
1859
2074
|
headers: {
|
|
1860
2075
|
type: "object",
|
|
@@ -2003,10 +2218,10 @@ var require_schemas = __commonJS({
|
|
|
2003
2218
|
maxLength: 4096
|
|
2004
2219
|
},
|
|
2005
2220
|
destination: {
|
|
2006
|
-
description: "An absolute pathname to an existing resource
|
|
2007
|
-
type: "string",
|
|
2008
|
-
maxLength: 4096
|
|
2221
|
+
description: "An absolute pathname to an existing resource, an external URL, or a service-targeted destination object.",
|
|
2222
|
+
anyOf: [{ type: "string", maxLength: 4096 }, serviceDestinationSchema]
|
|
2009
2223
|
},
|
|
2224
|
+
transforms: rewriteTransformsSchema,
|
|
2010
2225
|
has: hasSchema,
|
|
2011
2226
|
missing: hasSchema,
|
|
2012
2227
|
statusCode: {
|
|
@@ -2175,6 +2390,8 @@ var require_dist3 = __commonJS({
|
|
|
2175
2390
|
var src_exports2 = {};
|
|
2176
2391
|
__export2(src_exports2, {
|
|
2177
2392
|
appendRoutesToPhase: () => import_append.appendRoutesToPhase,
|
|
2393
|
+
compilePathToRegexpTemplate: () => import_superstatic2.compilePathToRegexpTemplate,
|
|
2394
|
+
convertRewrites: () => import_superstatic2.convertRewrites,
|
|
2178
2395
|
getCleanUrls: () => import_superstatic2.getCleanUrls,
|
|
2179
2396
|
getOwnershipGuard: () => import_service_route_ownership.getOwnershipGuard,
|
|
2180
2397
|
getTransformedRoutes: () => getTransformedRoutes2,
|
|
@@ -2183,6 +2400,7 @@ var require_dist3 = __commonJS({
|
|
|
2183
2400
|
mergeRoutes: () => import_merge.mergeRoutes,
|
|
2184
2401
|
normalizeRoutePrefix: () => import_service_route_ownership.normalizeRoutePrefix,
|
|
2185
2402
|
normalizeRoutes: () => normalizeRoutes,
|
|
2403
|
+
pathToRegexp: () => import_superstatic2.pathToRegexp,
|
|
2186
2404
|
scopeRouteSourceToOwnership: () => import_service_route_ownership.scopeRouteSourceToOwnership,
|
|
2187
2405
|
sourceToRegex: () => import_superstatic2.sourceToRegex
|
|
2188
2406
|
});
|
|
@@ -2226,8 +2444,12 @@ var require_dist3 = __commonJS({
|
|
|
2226
2444
|
`Route at index ${index} cannot define both \`dest\` and \`destination\`. Please use only one.`
|
|
2227
2445
|
);
|
|
2228
2446
|
}
|
|
2229
|
-
|
|
2230
|
-
|
|
2447
|
+
if (typeof route.destination === "string") {
|
|
2448
|
+
route.dest = route.destination;
|
|
2449
|
+
delete route.destination;
|
|
2450
|
+
} else if (typeof route.destination.service === "string") {
|
|
2451
|
+
route.destination = { ...route.destination, type: "service" };
|
|
2452
|
+
}
|
|
2231
2453
|
}
|
|
2232
2454
|
if (route.statusCode !== void 0) {
|
|
2233
2455
|
if (route.status !== void 0) {
|
|
@@ -2287,6 +2509,11 @@ var require_dist3 = __commonJS({
|
|
|
2287
2509
|
if (regError) {
|
|
2288
2510
|
errors.push(regError);
|
|
2289
2511
|
}
|
|
2512
|
+
if (route.destination && typeof route.destination === "object" && route.continue) {
|
|
2513
|
+
errors.push(
|
|
2514
|
+
`Route at index ${i} cannot define \`continue: true\` with a service \`destination\`. The service handoff is terminal.`
|
|
2515
|
+
);
|
|
2516
|
+
}
|
|
2290
2517
|
const handleValue = handling[handling.length - 1];
|
|
2291
2518
|
if (handleValue === "hit") {
|
|
2292
2519
|
if (route.dest) {
|
|
@@ -2341,7 +2568,8 @@ var require_dist3 = __commonJS({
|
|
|
2341
2568
|
function checkPatternSyntax(type, index, {
|
|
2342
2569
|
source,
|
|
2343
2570
|
destination,
|
|
2344
|
-
has
|
|
2571
|
+
has,
|
|
2572
|
+
transforms
|
|
2345
2573
|
}) {
|
|
2346
2574
|
let sourceSegments = /* @__PURE__ */ new Set();
|
|
2347
2575
|
const destinationSegments = /* @__PURE__ */ new Set();
|
|
@@ -2353,9 +2581,10 @@ var require_dist3 = __commonJS({
|
|
|
2353
2581
|
link: "https://vercel.link/invalid-route-source-pattern"
|
|
2354
2582
|
};
|
|
2355
2583
|
}
|
|
2356
|
-
|
|
2584
|
+
const destinationString = typeof destination === "string" ? destination : typeof destination?.path === "string" ? destination.path : void 0;
|
|
2585
|
+
if (destinationString !== void 0) {
|
|
2357
2586
|
try {
|
|
2358
|
-
const { hostname, pathname, query } = (0, import_url.parse)(
|
|
2587
|
+
const { hostname, pathname, query } = (0, import_url.parse)(destinationString, true);
|
|
2359
2588
|
(0, import_superstatic.sourceToRegex)(hostname || "").segments.forEach(
|
|
2360
2589
|
(name) => destinationSegments.add(name)
|
|
2361
2590
|
);
|
|
@@ -2380,6 +2609,19 @@ var require_dist3 = __commonJS({
|
|
|
2380
2609
|
}
|
|
2381
2610
|
}
|
|
2382
2611
|
}
|
|
2612
|
+
for (const transform of transforms || []) {
|
|
2613
|
+
if (transform.type !== "request.path") {
|
|
2614
|
+
continue;
|
|
2615
|
+
}
|
|
2616
|
+
try {
|
|
2617
|
+
(0, import_superstatic.compilePathToRegexpTemplate)(source, transform.args, has, transform.env);
|
|
2618
|
+
} catch (error) {
|
|
2619
|
+
return {
|
|
2620
|
+
message: `${type} at index ${index} has an invalid \`request.path\` transform: ${error instanceof Error ? error.message : String(error)}`,
|
|
2621
|
+
link: "https://vercel.link/invalid-route-destination-segment"
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2383
2625
|
return null;
|
|
2384
2626
|
}
|
|
2385
2627
|
function checkRedirect(r, index) {
|
|
@@ -2610,6 +2852,7 @@ var build = async ({
|
|
|
2610
2852
|
cliType,
|
|
2611
2853
|
lockfileVersion,
|
|
2612
2854
|
packageJsonPackageManager,
|
|
2855
|
+
nodeVersion,
|
|
2613
2856
|
env: process.env,
|
|
2614
2857
|
turboSupportsCorepackHome,
|
|
2615
2858
|
projectCreatedAt: config.projectSettings?.createdAt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/redwood",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@vercel/nft": "1.10.0",
|
|
17
17
|
"semver": "6.3.1",
|
|
18
18
|
"ts-morph": "12.0.0",
|
|
19
|
-
"@vercel/static-config": "3.4.
|
|
19
|
+
"@vercel/static-config": "3.4.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/aws-lambda": "8.10.19",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"@types/semver": "6.0.0",
|
|
25
25
|
"execa": "3.2.0",
|
|
26
26
|
"fs-extra": "11.1.0",
|
|
27
|
-
"vitest": "
|
|
28
|
-
"@vercel/build-utils": "
|
|
29
|
-
"@vercel/routing-utils": "6.
|
|
27
|
+
"vitest": "4.1.10",
|
|
28
|
+
"@vercel/build-utils": "14.1.1",
|
|
29
|
+
"@vercel/routing-utils": "6.5.0"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "node ../../utils/build-builder.mjs",
|
|
33
33
|
"type-check": "tsc --noEmit",
|
|
34
|
-
"
|
|
34
|
+
"test": "vitest run --config ../../vitest.config.mts"
|
|
35
35
|
}
|
|
36
36
|
}
|