@vercel/build-utils 14.0.5 → 14.1.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2808 -0
- package/dist/middleware-matcher.d.ts +15 -0
- package/dist/middleware-matcher.js +63 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -23103,6 +23103,2774 @@ var require_lib4 = __commonJS({
|
|
|
23103
23103
|
}
|
|
23104
23104
|
});
|
|
23105
23105
|
|
|
23106
|
+
// ../../node_modules/.pnpm/path-to-regexp@6.1.0/node_modules/path-to-regexp/dist/index.js
|
|
23107
|
+
var require_dist2 = __commonJS({
|
|
23108
|
+
"../../node_modules/.pnpm/path-to-regexp@6.1.0/node_modules/path-to-regexp/dist/index.js"(exports) {
|
|
23109
|
+
"use strict";
|
|
23110
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23111
|
+
function lexer(str) {
|
|
23112
|
+
var tokens = [];
|
|
23113
|
+
var i = 0;
|
|
23114
|
+
while (i < str.length) {
|
|
23115
|
+
var char = str[i];
|
|
23116
|
+
if (char === "*" || char === "+" || char === "?") {
|
|
23117
|
+
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
|
23118
|
+
continue;
|
|
23119
|
+
}
|
|
23120
|
+
if (char === "\\") {
|
|
23121
|
+
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
|
23122
|
+
continue;
|
|
23123
|
+
}
|
|
23124
|
+
if (char === "{") {
|
|
23125
|
+
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
|
23126
|
+
continue;
|
|
23127
|
+
}
|
|
23128
|
+
if (char === "}") {
|
|
23129
|
+
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
|
23130
|
+
continue;
|
|
23131
|
+
}
|
|
23132
|
+
if (char === ":") {
|
|
23133
|
+
var name = "";
|
|
23134
|
+
var j = i + 1;
|
|
23135
|
+
while (j < str.length) {
|
|
23136
|
+
var code = str.charCodeAt(j);
|
|
23137
|
+
if (
|
|
23138
|
+
// `0-9`
|
|
23139
|
+
code >= 48 && code <= 57 || // `A-Z`
|
|
23140
|
+
code >= 65 && code <= 90 || // `a-z`
|
|
23141
|
+
code >= 97 && code <= 122 || // `_`
|
|
23142
|
+
code === 95
|
|
23143
|
+
) {
|
|
23144
|
+
name += str[j++];
|
|
23145
|
+
continue;
|
|
23146
|
+
}
|
|
23147
|
+
break;
|
|
23148
|
+
}
|
|
23149
|
+
if (!name)
|
|
23150
|
+
throw new TypeError("Missing parameter name at " + i);
|
|
23151
|
+
tokens.push({ type: "NAME", index: i, value: name });
|
|
23152
|
+
i = j;
|
|
23153
|
+
continue;
|
|
23154
|
+
}
|
|
23155
|
+
if (char === "(") {
|
|
23156
|
+
var count = 1;
|
|
23157
|
+
var pattern = "";
|
|
23158
|
+
var j = i + 1;
|
|
23159
|
+
if (str[j] === "?") {
|
|
23160
|
+
throw new TypeError('Pattern cannot start with "?" at ' + j);
|
|
23161
|
+
}
|
|
23162
|
+
while (j < str.length) {
|
|
23163
|
+
if (str[j] === "\\") {
|
|
23164
|
+
pattern += str[j++] + str[j++];
|
|
23165
|
+
continue;
|
|
23166
|
+
}
|
|
23167
|
+
if (str[j] === ")") {
|
|
23168
|
+
count--;
|
|
23169
|
+
if (count === 0) {
|
|
23170
|
+
j++;
|
|
23171
|
+
break;
|
|
23172
|
+
}
|
|
23173
|
+
} else if (str[j] === "(") {
|
|
23174
|
+
count++;
|
|
23175
|
+
if (str[j + 1] !== "?") {
|
|
23176
|
+
throw new TypeError("Capturing groups are not allowed at " + j);
|
|
23177
|
+
}
|
|
23178
|
+
}
|
|
23179
|
+
pattern += str[j++];
|
|
23180
|
+
}
|
|
23181
|
+
if (count)
|
|
23182
|
+
throw new TypeError("Unbalanced pattern at " + i);
|
|
23183
|
+
if (!pattern)
|
|
23184
|
+
throw new TypeError("Missing pattern at " + i);
|
|
23185
|
+
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
|
23186
|
+
i = j;
|
|
23187
|
+
continue;
|
|
23188
|
+
}
|
|
23189
|
+
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
|
23190
|
+
}
|
|
23191
|
+
tokens.push({ type: "END", index: i, value: "" });
|
|
23192
|
+
return tokens;
|
|
23193
|
+
}
|
|
23194
|
+
function parse6(str, options) {
|
|
23195
|
+
if (options === void 0) {
|
|
23196
|
+
options = {};
|
|
23197
|
+
}
|
|
23198
|
+
var tokens = lexer(str);
|
|
23199
|
+
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
|
|
23200
|
+
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
|
|
23201
|
+
var result = [];
|
|
23202
|
+
var key = 0;
|
|
23203
|
+
var i = 0;
|
|
23204
|
+
var path8 = "";
|
|
23205
|
+
var tryConsume = function(type) {
|
|
23206
|
+
if (i < tokens.length && tokens[i].type === type)
|
|
23207
|
+
return tokens[i++].value;
|
|
23208
|
+
};
|
|
23209
|
+
var mustConsume = function(type) {
|
|
23210
|
+
var value2 = tryConsume(type);
|
|
23211
|
+
if (value2 !== void 0)
|
|
23212
|
+
return value2;
|
|
23213
|
+
var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
|
|
23214
|
+
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
|
|
23215
|
+
};
|
|
23216
|
+
var consumeText = function() {
|
|
23217
|
+
var result2 = "";
|
|
23218
|
+
var value2;
|
|
23219
|
+
while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
|
23220
|
+
result2 += value2;
|
|
23221
|
+
}
|
|
23222
|
+
return result2;
|
|
23223
|
+
};
|
|
23224
|
+
while (i < tokens.length) {
|
|
23225
|
+
var char = tryConsume("CHAR");
|
|
23226
|
+
var name = tryConsume("NAME");
|
|
23227
|
+
var pattern = tryConsume("PATTERN");
|
|
23228
|
+
if (name || pattern) {
|
|
23229
|
+
var prefix = char || "";
|
|
23230
|
+
if (prefixes.indexOf(prefix) === -1) {
|
|
23231
|
+
path8 += prefix;
|
|
23232
|
+
prefix = "";
|
|
23233
|
+
}
|
|
23234
|
+
if (path8) {
|
|
23235
|
+
result.push(path8);
|
|
23236
|
+
path8 = "";
|
|
23237
|
+
}
|
|
23238
|
+
result.push({
|
|
23239
|
+
name: name || key++,
|
|
23240
|
+
prefix,
|
|
23241
|
+
suffix: "",
|
|
23242
|
+
pattern: pattern || defaultPattern,
|
|
23243
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
23244
|
+
});
|
|
23245
|
+
continue;
|
|
23246
|
+
}
|
|
23247
|
+
var value = char || tryConsume("ESCAPED_CHAR");
|
|
23248
|
+
if (value) {
|
|
23249
|
+
path8 += value;
|
|
23250
|
+
continue;
|
|
23251
|
+
}
|
|
23252
|
+
if (path8) {
|
|
23253
|
+
result.push(path8);
|
|
23254
|
+
path8 = "";
|
|
23255
|
+
}
|
|
23256
|
+
var open = tryConsume("OPEN");
|
|
23257
|
+
if (open) {
|
|
23258
|
+
var prefix = consumeText();
|
|
23259
|
+
var name_1 = tryConsume("NAME") || "";
|
|
23260
|
+
var pattern_1 = tryConsume("PATTERN") || "";
|
|
23261
|
+
var suffix = consumeText();
|
|
23262
|
+
mustConsume("CLOSE");
|
|
23263
|
+
result.push({
|
|
23264
|
+
name: name_1 || (pattern_1 ? key++ : ""),
|
|
23265
|
+
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
|
|
23266
|
+
prefix,
|
|
23267
|
+
suffix,
|
|
23268
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
23269
|
+
});
|
|
23270
|
+
continue;
|
|
23271
|
+
}
|
|
23272
|
+
mustConsume("END");
|
|
23273
|
+
}
|
|
23274
|
+
return result;
|
|
23275
|
+
}
|
|
23276
|
+
exports.parse = parse6;
|
|
23277
|
+
function compile(str, options) {
|
|
23278
|
+
return tokensToFunction(parse6(str, options), options);
|
|
23279
|
+
}
|
|
23280
|
+
exports.compile = compile;
|
|
23281
|
+
function tokensToFunction(tokens, options) {
|
|
23282
|
+
if (options === void 0) {
|
|
23283
|
+
options = {};
|
|
23284
|
+
}
|
|
23285
|
+
var reFlags = flags(options);
|
|
23286
|
+
var _a = options.encode, encode = _a === void 0 ? function(x) {
|
|
23287
|
+
return x;
|
|
23288
|
+
} : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
|
|
23289
|
+
var matches = tokens.map(function(token) {
|
|
23290
|
+
if (typeof token === "object") {
|
|
23291
|
+
return new RegExp("^(?:" + token.pattern + ")$", reFlags);
|
|
23292
|
+
}
|
|
23293
|
+
});
|
|
23294
|
+
return function(data) {
|
|
23295
|
+
var path8 = "";
|
|
23296
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
23297
|
+
var token = tokens[i];
|
|
23298
|
+
if (typeof token === "string") {
|
|
23299
|
+
path8 += token;
|
|
23300
|
+
continue;
|
|
23301
|
+
}
|
|
23302
|
+
var value = data ? data[token.name] : void 0;
|
|
23303
|
+
var optional = token.modifier === "?" || token.modifier === "*";
|
|
23304
|
+
var repeat = token.modifier === "*" || token.modifier === "+";
|
|
23305
|
+
if (Array.isArray(value)) {
|
|
23306
|
+
if (!repeat) {
|
|
23307
|
+
throw new TypeError('Expected "' + token.name + '" to not repeat, but got an array');
|
|
23308
|
+
}
|
|
23309
|
+
if (value.length === 0) {
|
|
23310
|
+
if (optional)
|
|
23311
|
+
continue;
|
|
23312
|
+
throw new TypeError('Expected "' + token.name + '" to not be empty');
|
|
23313
|
+
}
|
|
23314
|
+
for (var j = 0; j < value.length; j++) {
|
|
23315
|
+
var segment = encode(value[j], token);
|
|
23316
|
+
if (validate && !matches[i].test(segment)) {
|
|
23317
|
+
throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"');
|
|
23318
|
+
}
|
|
23319
|
+
path8 += token.prefix + segment + token.suffix;
|
|
23320
|
+
}
|
|
23321
|
+
continue;
|
|
23322
|
+
}
|
|
23323
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
23324
|
+
var segment = encode(String(value), token);
|
|
23325
|
+
if (validate && !matches[i].test(segment)) {
|
|
23326
|
+
throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"');
|
|
23327
|
+
}
|
|
23328
|
+
path8 += token.prefix + segment + token.suffix;
|
|
23329
|
+
continue;
|
|
23330
|
+
}
|
|
23331
|
+
if (optional)
|
|
23332
|
+
continue;
|
|
23333
|
+
var typeOfMessage = repeat ? "an array" : "a string";
|
|
23334
|
+
throw new TypeError('Expected "' + token.name + '" to be ' + typeOfMessage);
|
|
23335
|
+
}
|
|
23336
|
+
return path8;
|
|
23337
|
+
};
|
|
23338
|
+
}
|
|
23339
|
+
exports.tokensToFunction = tokensToFunction;
|
|
23340
|
+
function match(str, options) {
|
|
23341
|
+
var keys = [];
|
|
23342
|
+
var re = pathToRegexp3(str, keys, options);
|
|
23343
|
+
return regexpToFunction(re, keys, options);
|
|
23344
|
+
}
|
|
23345
|
+
exports.match = match;
|
|
23346
|
+
function regexpToFunction(re, keys, options) {
|
|
23347
|
+
if (options === void 0) {
|
|
23348
|
+
options = {};
|
|
23349
|
+
}
|
|
23350
|
+
var _a = options.decode, decode = _a === void 0 ? function(x) {
|
|
23351
|
+
return x;
|
|
23352
|
+
} : _a;
|
|
23353
|
+
return function(pathname) {
|
|
23354
|
+
var m = re.exec(pathname);
|
|
23355
|
+
if (!m)
|
|
23356
|
+
return false;
|
|
23357
|
+
var path8 = m[0], index = m.index;
|
|
23358
|
+
var params = /* @__PURE__ */ Object.create(null);
|
|
23359
|
+
var _loop_1 = function(i2) {
|
|
23360
|
+
if (m[i2] === void 0)
|
|
23361
|
+
return "continue";
|
|
23362
|
+
var key = keys[i2 - 1];
|
|
23363
|
+
if (key.modifier === "*" || key.modifier === "+") {
|
|
23364
|
+
params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
|
|
23365
|
+
return decode(value, key);
|
|
23366
|
+
});
|
|
23367
|
+
} else {
|
|
23368
|
+
params[key.name] = decode(m[i2], key);
|
|
23369
|
+
}
|
|
23370
|
+
};
|
|
23371
|
+
for (var i = 1; i < m.length; i++) {
|
|
23372
|
+
_loop_1(i);
|
|
23373
|
+
}
|
|
23374
|
+
return { path: path8, index, params };
|
|
23375
|
+
};
|
|
23376
|
+
}
|
|
23377
|
+
exports.regexpToFunction = regexpToFunction;
|
|
23378
|
+
function escapeString(str) {
|
|
23379
|
+
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
23380
|
+
}
|
|
23381
|
+
function flags(options) {
|
|
23382
|
+
return options && options.sensitive ? "" : "i";
|
|
23383
|
+
}
|
|
23384
|
+
function regexpToRegexp(path8, keys) {
|
|
23385
|
+
if (!keys)
|
|
23386
|
+
return path8;
|
|
23387
|
+
var groups = path8.source.match(/\((?!\?)/g);
|
|
23388
|
+
if (groups) {
|
|
23389
|
+
for (var i = 0; i < groups.length; i++) {
|
|
23390
|
+
keys.push({
|
|
23391
|
+
name: i,
|
|
23392
|
+
prefix: "",
|
|
23393
|
+
suffix: "",
|
|
23394
|
+
modifier: "",
|
|
23395
|
+
pattern: ""
|
|
23396
|
+
});
|
|
23397
|
+
}
|
|
23398
|
+
}
|
|
23399
|
+
return path8;
|
|
23400
|
+
}
|
|
23401
|
+
function arrayToRegexp(paths, keys, options) {
|
|
23402
|
+
var parts = paths.map(function(path8) {
|
|
23403
|
+
return pathToRegexp3(path8, keys, options).source;
|
|
23404
|
+
});
|
|
23405
|
+
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
|
|
23406
|
+
}
|
|
23407
|
+
function stringToRegexp(path8, keys, options) {
|
|
23408
|
+
return tokensToRegexp(parse6(path8, options), keys, options);
|
|
23409
|
+
}
|
|
23410
|
+
function tokensToRegexp(tokens, keys, options) {
|
|
23411
|
+
if (options === void 0) {
|
|
23412
|
+
options = {};
|
|
23413
|
+
}
|
|
23414
|
+
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
|
23415
|
+
return x;
|
|
23416
|
+
} : _d;
|
|
23417
|
+
var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
|
|
23418
|
+
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
|
|
23419
|
+
var route = start ? "^" : "";
|
|
23420
|
+
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
23421
|
+
var token = tokens_1[_i];
|
|
23422
|
+
if (typeof token === "string") {
|
|
23423
|
+
route += escapeString(encode(token));
|
|
23424
|
+
} else {
|
|
23425
|
+
var prefix = escapeString(encode(token.prefix));
|
|
23426
|
+
var suffix = escapeString(encode(token.suffix));
|
|
23427
|
+
if (token.pattern) {
|
|
23428
|
+
if (keys)
|
|
23429
|
+
keys.push(token);
|
|
23430
|
+
if (prefix || suffix) {
|
|
23431
|
+
if (token.modifier === "+" || token.modifier === "*") {
|
|
23432
|
+
var mod = token.modifier === "*" ? "?" : "";
|
|
23433
|
+
route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
|
|
23434
|
+
} else {
|
|
23435
|
+
route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
|
|
23436
|
+
}
|
|
23437
|
+
} else {
|
|
23438
|
+
route += "(" + token.pattern + ")" + token.modifier;
|
|
23439
|
+
}
|
|
23440
|
+
} else {
|
|
23441
|
+
route += "(?:" + prefix + suffix + ")" + token.modifier;
|
|
23442
|
+
}
|
|
23443
|
+
}
|
|
23444
|
+
}
|
|
23445
|
+
if (end) {
|
|
23446
|
+
if (!strict)
|
|
23447
|
+
route += delimiter + "?";
|
|
23448
|
+
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
|
|
23449
|
+
} else {
|
|
23450
|
+
var endToken = tokens[tokens.length - 1];
|
|
23451
|
+
var isEndDelimited = typeof endToken === "string" ? delimiter.indexOf(endToken[endToken.length - 1]) > -1 : (
|
|
23452
|
+
// tslint:disable-next-line
|
|
23453
|
+
endToken === void 0
|
|
23454
|
+
);
|
|
23455
|
+
if (!strict) {
|
|
23456
|
+
route += "(?:" + delimiter + "(?=" + endsWith + "))?";
|
|
23457
|
+
}
|
|
23458
|
+
if (!isEndDelimited) {
|
|
23459
|
+
route += "(?=" + delimiter + "|" + endsWith + ")";
|
|
23460
|
+
}
|
|
23461
|
+
}
|
|
23462
|
+
return new RegExp(route, flags(options));
|
|
23463
|
+
}
|
|
23464
|
+
exports.tokensToRegexp = tokensToRegexp;
|
|
23465
|
+
function pathToRegexp3(path8, keys, options) {
|
|
23466
|
+
if (path8 instanceof RegExp)
|
|
23467
|
+
return regexpToRegexp(path8, keys);
|
|
23468
|
+
if (Array.isArray(path8))
|
|
23469
|
+
return arrayToRegexp(path8, keys, options);
|
|
23470
|
+
return stringToRegexp(path8, keys, options);
|
|
23471
|
+
}
|
|
23472
|
+
exports.pathToRegexp = pathToRegexp3;
|
|
23473
|
+
}
|
|
23474
|
+
});
|
|
23475
|
+
|
|
23476
|
+
// ../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist/index.js
|
|
23477
|
+
var require_dist3 = __commonJS({
|
|
23478
|
+
"../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist/index.js"(exports) {
|
|
23479
|
+
"use strict";
|
|
23480
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23481
|
+
exports.pathToRegexp = exports.tokensToRegexp = exports.regexpToFunction = exports.match = exports.tokensToFunction = exports.compile = exports.parse = void 0;
|
|
23482
|
+
function lexer(str) {
|
|
23483
|
+
var tokens = [];
|
|
23484
|
+
var i = 0;
|
|
23485
|
+
while (i < str.length) {
|
|
23486
|
+
var char = str[i];
|
|
23487
|
+
if (char === "*" || char === "+" || char === "?") {
|
|
23488
|
+
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
|
23489
|
+
continue;
|
|
23490
|
+
}
|
|
23491
|
+
if (char === "\\") {
|
|
23492
|
+
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
|
23493
|
+
continue;
|
|
23494
|
+
}
|
|
23495
|
+
if (char === "{") {
|
|
23496
|
+
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
|
23497
|
+
continue;
|
|
23498
|
+
}
|
|
23499
|
+
if (char === "}") {
|
|
23500
|
+
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
|
23501
|
+
continue;
|
|
23502
|
+
}
|
|
23503
|
+
if (char === ":") {
|
|
23504
|
+
var name = "";
|
|
23505
|
+
var j = i + 1;
|
|
23506
|
+
while (j < str.length) {
|
|
23507
|
+
var code = str.charCodeAt(j);
|
|
23508
|
+
if (
|
|
23509
|
+
// `0-9`
|
|
23510
|
+
code >= 48 && code <= 57 || // `A-Z`
|
|
23511
|
+
code >= 65 && code <= 90 || // `a-z`
|
|
23512
|
+
code >= 97 && code <= 122 || // `_`
|
|
23513
|
+
code === 95
|
|
23514
|
+
) {
|
|
23515
|
+
name += str[j++];
|
|
23516
|
+
continue;
|
|
23517
|
+
}
|
|
23518
|
+
break;
|
|
23519
|
+
}
|
|
23520
|
+
if (!name)
|
|
23521
|
+
throw new TypeError("Missing parameter name at ".concat(i));
|
|
23522
|
+
tokens.push({ type: "NAME", index: i, value: name });
|
|
23523
|
+
i = j;
|
|
23524
|
+
continue;
|
|
23525
|
+
}
|
|
23526
|
+
if (char === "(") {
|
|
23527
|
+
var count = 1;
|
|
23528
|
+
var pattern = "";
|
|
23529
|
+
var j = i + 1;
|
|
23530
|
+
if (str[j] === "?") {
|
|
23531
|
+
throw new TypeError('Pattern cannot start with "?" at '.concat(j));
|
|
23532
|
+
}
|
|
23533
|
+
while (j < str.length) {
|
|
23534
|
+
if (str[j] === "\\") {
|
|
23535
|
+
pattern += str[j++] + str[j++];
|
|
23536
|
+
continue;
|
|
23537
|
+
}
|
|
23538
|
+
if (str[j] === ")") {
|
|
23539
|
+
count--;
|
|
23540
|
+
if (count === 0) {
|
|
23541
|
+
j++;
|
|
23542
|
+
break;
|
|
23543
|
+
}
|
|
23544
|
+
} else if (str[j] === "(") {
|
|
23545
|
+
count++;
|
|
23546
|
+
if (str[j + 1] !== "?") {
|
|
23547
|
+
throw new TypeError("Capturing groups are not allowed at ".concat(j));
|
|
23548
|
+
}
|
|
23549
|
+
}
|
|
23550
|
+
pattern += str[j++];
|
|
23551
|
+
}
|
|
23552
|
+
if (count)
|
|
23553
|
+
throw new TypeError("Unbalanced pattern at ".concat(i));
|
|
23554
|
+
if (!pattern)
|
|
23555
|
+
throw new TypeError("Missing pattern at ".concat(i));
|
|
23556
|
+
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
|
23557
|
+
i = j;
|
|
23558
|
+
continue;
|
|
23559
|
+
}
|
|
23560
|
+
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
|
23561
|
+
}
|
|
23562
|
+
tokens.push({ type: "END", index: i, value: "" });
|
|
23563
|
+
return tokens;
|
|
23564
|
+
}
|
|
23565
|
+
function parse6(str, options) {
|
|
23566
|
+
if (options === void 0) {
|
|
23567
|
+
options = {};
|
|
23568
|
+
}
|
|
23569
|
+
var tokens = lexer(str);
|
|
23570
|
+
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
|
|
23571
|
+
var result = [];
|
|
23572
|
+
var key = 0;
|
|
23573
|
+
var i = 0;
|
|
23574
|
+
var path8 = "";
|
|
23575
|
+
var tryConsume = function(type) {
|
|
23576
|
+
if (i < tokens.length && tokens[i].type === type)
|
|
23577
|
+
return tokens[i++].value;
|
|
23578
|
+
};
|
|
23579
|
+
var mustConsume = function(type) {
|
|
23580
|
+
var value2 = tryConsume(type);
|
|
23581
|
+
if (value2 !== void 0)
|
|
23582
|
+
return value2;
|
|
23583
|
+
var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
|
|
23584
|
+
throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
|
|
23585
|
+
};
|
|
23586
|
+
var consumeText = function() {
|
|
23587
|
+
var result2 = "";
|
|
23588
|
+
var value2;
|
|
23589
|
+
while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
|
23590
|
+
result2 += value2;
|
|
23591
|
+
}
|
|
23592
|
+
return result2;
|
|
23593
|
+
};
|
|
23594
|
+
var isSafe = function(value2) {
|
|
23595
|
+
for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
|
|
23596
|
+
var char2 = delimiter_1[_i];
|
|
23597
|
+
if (value2.indexOf(char2) > -1)
|
|
23598
|
+
return true;
|
|
23599
|
+
}
|
|
23600
|
+
return false;
|
|
23601
|
+
};
|
|
23602
|
+
var safePattern = function(prefix2) {
|
|
23603
|
+
var prev = result[result.length - 1];
|
|
23604
|
+
var prevText = prefix2 || (prev && typeof prev === "string" ? prev : "");
|
|
23605
|
+
if (prev && !prevText) {
|
|
23606
|
+
throw new TypeError('Must have text between two parameters, missing text after "'.concat(prev.name, '"'));
|
|
23607
|
+
}
|
|
23608
|
+
if (!prevText || isSafe(prevText))
|
|
23609
|
+
return "[^".concat(escapeString(delimiter), "]+?");
|
|
23610
|
+
return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
|
|
23611
|
+
};
|
|
23612
|
+
while (i < tokens.length) {
|
|
23613
|
+
var char = tryConsume("CHAR");
|
|
23614
|
+
var name = tryConsume("NAME");
|
|
23615
|
+
var pattern = tryConsume("PATTERN");
|
|
23616
|
+
if (name || pattern) {
|
|
23617
|
+
var prefix = char || "";
|
|
23618
|
+
if (prefixes.indexOf(prefix) === -1) {
|
|
23619
|
+
path8 += prefix;
|
|
23620
|
+
prefix = "";
|
|
23621
|
+
}
|
|
23622
|
+
if (path8) {
|
|
23623
|
+
result.push(path8);
|
|
23624
|
+
path8 = "";
|
|
23625
|
+
}
|
|
23626
|
+
result.push({
|
|
23627
|
+
name: name || key++,
|
|
23628
|
+
prefix,
|
|
23629
|
+
suffix: "",
|
|
23630
|
+
pattern: pattern || safePattern(prefix),
|
|
23631
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
23632
|
+
});
|
|
23633
|
+
continue;
|
|
23634
|
+
}
|
|
23635
|
+
var value = char || tryConsume("ESCAPED_CHAR");
|
|
23636
|
+
if (value) {
|
|
23637
|
+
path8 += value;
|
|
23638
|
+
continue;
|
|
23639
|
+
}
|
|
23640
|
+
if (path8) {
|
|
23641
|
+
result.push(path8);
|
|
23642
|
+
path8 = "";
|
|
23643
|
+
}
|
|
23644
|
+
var open = tryConsume("OPEN");
|
|
23645
|
+
if (open) {
|
|
23646
|
+
var prefix = consumeText();
|
|
23647
|
+
var name_1 = tryConsume("NAME") || "";
|
|
23648
|
+
var pattern_1 = tryConsume("PATTERN") || "";
|
|
23649
|
+
var suffix = consumeText();
|
|
23650
|
+
mustConsume("CLOSE");
|
|
23651
|
+
result.push({
|
|
23652
|
+
name: name_1 || (pattern_1 ? key++ : ""),
|
|
23653
|
+
pattern: name_1 && !pattern_1 ? safePattern(prefix) : pattern_1,
|
|
23654
|
+
prefix,
|
|
23655
|
+
suffix,
|
|
23656
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
23657
|
+
});
|
|
23658
|
+
continue;
|
|
23659
|
+
}
|
|
23660
|
+
mustConsume("END");
|
|
23661
|
+
}
|
|
23662
|
+
return result;
|
|
23663
|
+
}
|
|
23664
|
+
exports.parse = parse6;
|
|
23665
|
+
function compile(str, options) {
|
|
23666
|
+
return tokensToFunction(parse6(str, options), options);
|
|
23667
|
+
}
|
|
23668
|
+
exports.compile = compile;
|
|
23669
|
+
function tokensToFunction(tokens, options) {
|
|
23670
|
+
if (options === void 0) {
|
|
23671
|
+
options = {};
|
|
23672
|
+
}
|
|
23673
|
+
var reFlags = flags(options);
|
|
23674
|
+
var _a = options.encode, encode = _a === void 0 ? function(x) {
|
|
23675
|
+
return x;
|
|
23676
|
+
} : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
|
|
23677
|
+
var matches = tokens.map(function(token) {
|
|
23678
|
+
if (typeof token === "object") {
|
|
23679
|
+
return new RegExp("^(?:".concat(token.pattern, ")$"), reFlags);
|
|
23680
|
+
}
|
|
23681
|
+
});
|
|
23682
|
+
return function(data) {
|
|
23683
|
+
var path8 = "";
|
|
23684
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
23685
|
+
var token = tokens[i];
|
|
23686
|
+
if (typeof token === "string") {
|
|
23687
|
+
path8 += token;
|
|
23688
|
+
continue;
|
|
23689
|
+
}
|
|
23690
|
+
var value = data ? data[token.name] : void 0;
|
|
23691
|
+
var optional = token.modifier === "?" || token.modifier === "*";
|
|
23692
|
+
var repeat = token.modifier === "*" || token.modifier === "+";
|
|
23693
|
+
if (Array.isArray(value)) {
|
|
23694
|
+
if (!repeat) {
|
|
23695
|
+
throw new TypeError('Expected "'.concat(token.name, '" to not repeat, but got an array'));
|
|
23696
|
+
}
|
|
23697
|
+
if (value.length === 0) {
|
|
23698
|
+
if (optional)
|
|
23699
|
+
continue;
|
|
23700
|
+
throw new TypeError('Expected "'.concat(token.name, '" to not be empty'));
|
|
23701
|
+
}
|
|
23702
|
+
for (var j = 0; j < value.length; j++) {
|
|
23703
|
+
var segment = encode(value[j], token);
|
|
23704
|
+
if (validate && !matches[i].test(segment)) {
|
|
23705
|
+
throw new TypeError('Expected all "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
|
|
23706
|
+
}
|
|
23707
|
+
path8 += token.prefix + segment + token.suffix;
|
|
23708
|
+
}
|
|
23709
|
+
continue;
|
|
23710
|
+
}
|
|
23711
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
23712
|
+
var segment = encode(String(value), token);
|
|
23713
|
+
if (validate && !matches[i].test(segment)) {
|
|
23714
|
+
throw new TypeError('Expected "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
|
|
23715
|
+
}
|
|
23716
|
+
path8 += token.prefix + segment + token.suffix;
|
|
23717
|
+
continue;
|
|
23718
|
+
}
|
|
23719
|
+
if (optional)
|
|
23720
|
+
continue;
|
|
23721
|
+
var typeOfMessage = repeat ? "an array" : "a string";
|
|
23722
|
+
throw new TypeError('Expected "'.concat(token.name, '" to be ').concat(typeOfMessage));
|
|
23723
|
+
}
|
|
23724
|
+
return path8;
|
|
23725
|
+
};
|
|
23726
|
+
}
|
|
23727
|
+
exports.tokensToFunction = tokensToFunction;
|
|
23728
|
+
function match(str, options) {
|
|
23729
|
+
var keys = [];
|
|
23730
|
+
var re = pathToRegexp3(str, keys, options);
|
|
23731
|
+
return regexpToFunction(re, keys, options);
|
|
23732
|
+
}
|
|
23733
|
+
exports.match = match;
|
|
23734
|
+
function regexpToFunction(re, keys, options) {
|
|
23735
|
+
if (options === void 0) {
|
|
23736
|
+
options = {};
|
|
23737
|
+
}
|
|
23738
|
+
var _a = options.decode, decode = _a === void 0 ? function(x) {
|
|
23739
|
+
return x;
|
|
23740
|
+
} : _a;
|
|
23741
|
+
return function(pathname) {
|
|
23742
|
+
var m = re.exec(pathname);
|
|
23743
|
+
if (!m)
|
|
23744
|
+
return false;
|
|
23745
|
+
var path8 = m[0], index = m.index;
|
|
23746
|
+
var params = /* @__PURE__ */ Object.create(null);
|
|
23747
|
+
var _loop_1 = function(i2) {
|
|
23748
|
+
if (m[i2] === void 0)
|
|
23749
|
+
return "continue";
|
|
23750
|
+
var key = keys[i2 - 1];
|
|
23751
|
+
if (key.modifier === "*" || key.modifier === "+") {
|
|
23752
|
+
params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
|
|
23753
|
+
return decode(value, key);
|
|
23754
|
+
});
|
|
23755
|
+
} else {
|
|
23756
|
+
params[key.name] = decode(m[i2], key);
|
|
23757
|
+
}
|
|
23758
|
+
};
|
|
23759
|
+
for (var i = 1; i < m.length; i++) {
|
|
23760
|
+
_loop_1(i);
|
|
23761
|
+
}
|
|
23762
|
+
return { path: path8, index, params };
|
|
23763
|
+
};
|
|
23764
|
+
}
|
|
23765
|
+
exports.regexpToFunction = regexpToFunction;
|
|
23766
|
+
function escapeString(str) {
|
|
23767
|
+
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
23768
|
+
}
|
|
23769
|
+
function flags(options) {
|
|
23770
|
+
return options && options.sensitive ? "" : "i";
|
|
23771
|
+
}
|
|
23772
|
+
function regexpToRegexp(path8, keys) {
|
|
23773
|
+
if (!keys)
|
|
23774
|
+
return path8;
|
|
23775
|
+
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
|
|
23776
|
+
var index = 0;
|
|
23777
|
+
var execResult = groupsRegex.exec(path8.source);
|
|
23778
|
+
while (execResult) {
|
|
23779
|
+
keys.push({
|
|
23780
|
+
// Use parenthesized substring match if available, index otherwise
|
|
23781
|
+
name: execResult[1] || index++,
|
|
23782
|
+
prefix: "",
|
|
23783
|
+
suffix: "",
|
|
23784
|
+
modifier: "",
|
|
23785
|
+
pattern: ""
|
|
23786
|
+
});
|
|
23787
|
+
execResult = groupsRegex.exec(path8.source);
|
|
23788
|
+
}
|
|
23789
|
+
return path8;
|
|
23790
|
+
}
|
|
23791
|
+
function arrayToRegexp(paths, keys, options) {
|
|
23792
|
+
var parts = paths.map(function(path8) {
|
|
23793
|
+
return pathToRegexp3(path8, keys, options).source;
|
|
23794
|
+
});
|
|
23795
|
+
return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
|
|
23796
|
+
}
|
|
23797
|
+
function stringToRegexp(path8, keys, options) {
|
|
23798
|
+
return tokensToRegexp(parse6(path8, options), keys, options);
|
|
23799
|
+
}
|
|
23800
|
+
function tokensToRegexp(tokens, keys, options) {
|
|
23801
|
+
if (options === void 0) {
|
|
23802
|
+
options = {};
|
|
23803
|
+
}
|
|
23804
|
+
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
|
23805
|
+
return x;
|
|
23806
|
+
} : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
|
|
23807
|
+
var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
|
|
23808
|
+
var delimiterRe = "[".concat(escapeString(delimiter), "]");
|
|
23809
|
+
var route = start ? "^" : "";
|
|
23810
|
+
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
23811
|
+
var token = tokens_1[_i];
|
|
23812
|
+
if (typeof token === "string") {
|
|
23813
|
+
route += escapeString(encode(token));
|
|
23814
|
+
} else {
|
|
23815
|
+
var prefix = escapeString(encode(token.prefix));
|
|
23816
|
+
var suffix = escapeString(encode(token.suffix));
|
|
23817
|
+
if (token.pattern) {
|
|
23818
|
+
if (keys)
|
|
23819
|
+
keys.push(token);
|
|
23820
|
+
if (prefix || suffix) {
|
|
23821
|
+
if (token.modifier === "+" || token.modifier === "*") {
|
|
23822
|
+
var mod = token.modifier === "*" ? "?" : "";
|
|
23823
|
+
route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
|
|
23824
|
+
} else {
|
|
23825
|
+
route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
|
|
23826
|
+
}
|
|
23827
|
+
} else {
|
|
23828
|
+
if (token.modifier === "+" || token.modifier === "*") {
|
|
23829
|
+
throw new TypeError('Can not repeat "'.concat(token.name, '" without a prefix and suffix'));
|
|
23830
|
+
}
|
|
23831
|
+
route += "(".concat(token.pattern, ")").concat(token.modifier);
|
|
23832
|
+
}
|
|
23833
|
+
} else {
|
|
23834
|
+
route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
|
|
23835
|
+
}
|
|
23836
|
+
}
|
|
23837
|
+
}
|
|
23838
|
+
if (end) {
|
|
23839
|
+
if (!strict)
|
|
23840
|
+
route += "".concat(delimiterRe, "?");
|
|
23841
|
+
route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
|
|
23842
|
+
} else {
|
|
23843
|
+
var endToken = tokens[tokens.length - 1];
|
|
23844
|
+
var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
|
|
23845
|
+
if (!strict) {
|
|
23846
|
+
route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
|
|
23847
|
+
}
|
|
23848
|
+
if (!isEndDelimited) {
|
|
23849
|
+
route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
|
|
23850
|
+
}
|
|
23851
|
+
}
|
|
23852
|
+
return new RegExp(route, flags(options));
|
|
23853
|
+
}
|
|
23854
|
+
exports.tokensToRegexp = tokensToRegexp;
|
|
23855
|
+
function pathToRegexp3(path8, keys, options) {
|
|
23856
|
+
if (path8 instanceof RegExp)
|
|
23857
|
+
return regexpToRegexp(path8, keys);
|
|
23858
|
+
if (Array.isArray(path8))
|
|
23859
|
+
return arrayToRegexp(path8, keys, options);
|
|
23860
|
+
return stringToRegexp(path8, keys, options);
|
|
23861
|
+
}
|
|
23862
|
+
exports.pathToRegexp = pathToRegexp3;
|
|
23863
|
+
}
|
|
23864
|
+
});
|
|
23865
|
+
|
|
23866
|
+
// ../routing-utils/dist/superstatic.js
|
|
23867
|
+
var require_superstatic = __commonJS({
|
|
23868
|
+
"../routing-utils/dist/superstatic.js"(exports, module2) {
|
|
23869
|
+
"use strict";
|
|
23870
|
+
var __defProp2 = Object.defineProperty;
|
|
23871
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
23872
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
23873
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
23874
|
+
var __export2 = (target, all) => {
|
|
23875
|
+
for (var name in all)
|
|
23876
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
23877
|
+
};
|
|
23878
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
23879
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23880
|
+
for (let key of __getOwnPropNames2(from))
|
|
23881
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
23882
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
23883
|
+
}
|
|
23884
|
+
return to;
|
|
23885
|
+
};
|
|
23886
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
23887
|
+
var superstatic_exports = {};
|
|
23888
|
+
__export2(superstatic_exports, {
|
|
23889
|
+
collectHasSegments: () => collectHasSegments,
|
|
23890
|
+
compilePathToRegexpTemplate: () => compilePathToRegexpTemplate2,
|
|
23891
|
+
convertCleanUrls: () => convertCleanUrls,
|
|
23892
|
+
convertHeaders: () => convertHeaders,
|
|
23893
|
+
convertRedirects: () => convertRedirects,
|
|
23894
|
+
convertRewrites: () => convertRewrites2,
|
|
23895
|
+
convertTrailingSlash: () => convertTrailingSlash,
|
|
23896
|
+
getCleanUrls: () => getCleanUrls2,
|
|
23897
|
+
pathToRegexp: () => pathToRegexp3,
|
|
23898
|
+
sourceToRegex: () => sourceToRegex2
|
|
23899
|
+
});
|
|
23900
|
+
module2.exports = __toCommonJS2(superstatic_exports);
|
|
23901
|
+
var import_url = require("url");
|
|
23902
|
+
var import_path_to_regexp = require_dist2();
|
|
23903
|
+
var import_path_to_regexp_updated = require_dist3();
|
|
23904
|
+
function cloneKeys(keys) {
|
|
23905
|
+
if (typeof keys === "undefined") {
|
|
23906
|
+
return void 0;
|
|
23907
|
+
}
|
|
23908
|
+
return keys.slice(0);
|
|
23909
|
+
}
|
|
23910
|
+
function compareKeys(left, right) {
|
|
23911
|
+
const leftSerialized = typeof left === "undefined" ? "undefined" : left.toString();
|
|
23912
|
+
const rightSerialized = typeof right === "undefined" ? "undefined" : right.toString();
|
|
23913
|
+
return leftSerialized === rightSerialized;
|
|
23914
|
+
}
|
|
23915
|
+
function pathToRegexp3(callerId, path8, keys, options) {
|
|
23916
|
+
const newKeys = cloneKeys(keys);
|
|
23917
|
+
const currentRegExp = (0, import_path_to_regexp.pathToRegexp)(path8, keys, options);
|
|
23918
|
+
try {
|
|
23919
|
+
const currentKeys = keys;
|
|
23920
|
+
const newRegExp = (0, import_path_to_regexp_updated.pathToRegexp)(path8, newKeys, options);
|
|
23921
|
+
const isDiffRegExp = currentRegExp.toString() !== newRegExp.toString();
|
|
23922
|
+
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffRegExp) {
|
|
23923
|
+
const message = JSON.stringify({
|
|
23924
|
+
path: path8,
|
|
23925
|
+
currentRegExp: currentRegExp.toString(),
|
|
23926
|
+
newRegExp: newRegExp.toString()
|
|
23927
|
+
});
|
|
23928
|
+
console.error(`[vc] PATH TO REGEXP PATH DIFF @ #${callerId}: ${message}`);
|
|
23929
|
+
}
|
|
23930
|
+
const isDiffKeys = !compareKeys(keys, newKeys);
|
|
23931
|
+
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffKeys) {
|
|
23932
|
+
const message = JSON.stringify({
|
|
23933
|
+
isDiffKeys,
|
|
23934
|
+
currentKeys,
|
|
23935
|
+
newKeys
|
|
23936
|
+
});
|
|
23937
|
+
console.error(`[vc] PATH TO REGEXP KEYS DIFF @ #${callerId}: ${message}`);
|
|
23938
|
+
}
|
|
23939
|
+
} catch (err) {
|
|
23940
|
+
const error = err;
|
|
23941
|
+
const message = JSON.stringify({
|
|
23942
|
+
path: path8,
|
|
23943
|
+
error: error.message
|
|
23944
|
+
});
|
|
23945
|
+
console.error(`[vc] PATH TO REGEXP ERROR @ #${callerId}: ${message}`);
|
|
23946
|
+
}
|
|
23947
|
+
return currentRegExp;
|
|
23948
|
+
}
|
|
23949
|
+
var UN_NAMED_SEGMENT = "__UN_NAMED_SEGMENT__";
|
|
23950
|
+
function getCleanUrls2(filePaths) {
|
|
23951
|
+
const htmlFiles = filePaths.map(toRoute).filter((f) => f.endsWith(".html")).map((f) => ({
|
|
23952
|
+
html: f,
|
|
23953
|
+
clean: f.slice(0, -5)
|
|
23954
|
+
}));
|
|
23955
|
+
return htmlFiles;
|
|
23956
|
+
}
|
|
23957
|
+
function convertCleanUrls(cleanUrls, trailingSlash, status = 308) {
|
|
23958
|
+
const routes = [];
|
|
23959
|
+
if (cleanUrls) {
|
|
23960
|
+
const loc = trailingSlash ? "/$1/" : "/$1";
|
|
23961
|
+
routes.push({
|
|
23962
|
+
src: "^/(?:(.+)/)?index(?:\\.html)?/?$",
|
|
23963
|
+
headers: { Location: loc },
|
|
23964
|
+
status
|
|
23965
|
+
});
|
|
23966
|
+
routes.push({
|
|
23967
|
+
src: "^/(.*)\\.html/?$",
|
|
23968
|
+
headers: { Location: loc },
|
|
23969
|
+
status
|
|
23970
|
+
});
|
|
23971
|
+
}
|
|
23972
|
+
return routes;
|
|
23973
|
+
}
|
|
23974
|
+
function convertRedirects(redirects, defaultStatus = 308) {
|
|
23975
|
+
return redirects.map((r) => {
|
|
23976
|
+
const { src, segments } = sourceToRegex2(r.source);
|
|
23977
|
+
const hasSegments = collectHasSegments(r.has);
|
|
23978
|
+
normalizeHasKeys(r.has);
|
|
23979
|
+
normalizeHasKeys(r.missing);
|
|
23980
|
+
try {
|
|
23981
|
+
const loc = replaceSegments(segments, hasSegments, r.destination, true);
|
|
23982
|
+
let status;
|
|
23983
|
+
if (typeof r.permanent === "boolean") {
|
|
23984
|
+
status = r.permanent ? 308 : 307;
|
|
23985
|
+
} else if (r.statusCode) {
|
|
23986
|
+
status = r.statusCode;
|
|
23987
|
+
} else {
|
|
23988
|
+
status = defaultStatus;
|
|
23989
|
+
}
|
|
23990
|
+
const route = {
|
|
23991
|
+
src,
|
|
23992
|
+
headers: { Location: loc },
|
|
23993
|
+
status
|
|
23994
|
+
};
|
|
23995
|
+
if (typeof r.env !== "undefined") {
|
|
23996
|
+
route.env = r.env;
|
|
23997
|
+
}
|
|
23998
|
+
if (r.has) {
|
|
23999
|
+
route.has = r.has;
|
|
24000
|
+
}
|
|
24001
|
+
if (r.missing) {
|
|
24002
|
+
route.missing = r.missing;
|
|
24003
|
+
}
|
|
24004
|
+
return route;
|
|
24005
|
+
} catch (_e) {
|
|
24006
|
+
throw new Error(`Failed to parse redirect: ${JSON.stringify(r)}`);
|
|
24007
|
+
}
|
|
24008
|
+
});
|
|
24009
|
+
}
|
|
24010
|
+
function convertRewrites2(rewrites, internalParamNames) {
|
|
24011
|
+
return rewrites.map((r) => {
|
|
24012
|
+
const { src, segments } = sourceToRegex2(r.source);
|
|
24013
|
+
const hasSegments = collectHasSegments(r.has);
|
|
24014
|
+
normalizeHasKeys(r.has);
|
|
24015
|
+
normalizeHasKeys(r.missing);
|
|
24016
|
+
try {
|
|
24017
|
+
const interpolate = (value) => replaceSegments(
|
|
24018
|
+
segments,
|
|
24019
|
+
hasSegments,
|
|
24020
|
+
value,
|
|
24021
|
+
false,
|
|
24022
|
+
internalParamNames
|
|
24023
|
+
);
|
|
24024
|
+
let route;
|
|
24025
|
+
if (typeof r.destination === "string") {
|
|
24026
|
+
route = { src, dest: interpolate(r.destination), check: true };
|
|
24027
|
+
} else {
|
|
24028
|
+
const destination = { ...r.destination, type: "service" };
|
|
24029
|
+
if (typeof destination.path === "string") {
|
|
24030
|
+
destination.path = interpolate(destination.path);
|
|
24031
|
+
}
|
|
24032
|
+
route = { src, destination };
|
|
24033
|
+
}
|
|
24034
|
+
if (r.transforms) {
|
|
24035
|
+
route.transforms = r.transforms.map((transform) => {
|
|
24036
|
+
if (transform.type !== "request.path") {
|
|
24037
|
+
return { ...transform };
|
|
24038
|
+
}
|
|
24039
|
+
return {
|
|
24040
|
+
...transform,
|
|
24041
|
+
args: compilePathToRegexpTemplateFromSegments(
|
|
24042
|
+
transform.args,
|
|
24043
|
+
segments,
|
|
24044
|
+
hasSegments,
|
|
24045
|
+
transform.env
|
|
24046
|
+
)
|
|
24047
|
+
};
|
|
24048
|
+
});
|
|
24049
|
+
}
|
|
24050
|
+
if (typeof r.env !== "undefined") {
|
|
24051
|
+
route.env = r.env;
|
|
24052
|
+
}
|
|
24053
|
+
if (r.has) {
|
|
24054
|
+
route.has = r.has;
|
|
24055
|
+
}
|
|
24056
|
+
if (r.missing) {
|
|
24057
|
+
route.missing = r.missing;
|
|
24058
|
+
}
|
|
24059
|
+
if (r.statusCode) {
|
|
24060
|
+
route.status = r.statusCode;
|
|
24061
|
+
}
|
|
24062
|
+
return route;
|
|
24063
|
+
} catch (_e) {
|
|
24064
|
+
throw new Error(`Failed to parse rewrite: ${JSON.stringify(r)}`);
|
|
24065
|
+
}
|
|
24066
|
+
});
|
|
24067
|
+
}
|
|
24068
|
+
function convertHeaders(headers) {
|
|
24069
|
+
return headers.map((h) => {
|
|
24070
|
+
const obj = {};
|
|
24071
|
+
const { src, segments } = sourceToRegex2(h.source);
|
|
24072
|
+
const hasSegments = collectHasSegments(h.has);
|
|
24073
|
+
normalizeHasKeys(h.has);
|
|
24074
|
+
normalizeHasKeys(h.missing);
|
|
24075
|
+
const namedSegments = segments.filter((name) => name !== UN_NAMED_SEGMENT);
|
|
24076
|
+
const indexes = {};
|
|
24077
|
+
segments.forEach((name, index) => {
|
|
24078
|
+
indexes[name] = toSegmentDest(index);
|
|
24079
|
+
});
|
|
24080
|
+
hasSegments.forEach((name) => {
|
|
24081
|
+
indexes[name] = "$" + name;
|
|
24082
|
+
});
|
|
24083
|
+
h.headers.forEach(({ key, value }) => {
|
|
24084
|
+
if (namedSegments.length > 0 || hasSegments.length > 0) {
|
|
24085
|
+
if (key.includes(":")) {
|
|
24086
|
+
key = safelyCompile(key, indexes);
|
|
24087
|
+
}
|
|
24088
|
+
if (value.includes(":")) {
|
|
24089
|
+
value = safelyCompile(value, indexes);
|
|
24090
|
+
}
|
|
24091
|
+
}
|
|
24092
|
+
obj[key] = value;
|
|
24093
|
+
});
|
|
24094
|
+
const route = {
|
|
24095
|
+
src,
|
|
24096
|
+
headers: obj,
|
|
24097
|
+
continue: true
|
|
24098
|
+
};
|
|
24099
|
+
if (h.has) {
|
|
24100
|
+
route.has = h.has;
|
|
24101
|
+
}
|
|
24102
|
+
if (h.missing) {
|
|
24103
|
+
route.missing = h.missing;
|
|
24104
|
+
}
|
|
24105
|
+
return route;
|
|
24106
|
+
});
|
|
24107
|
+
}
|
|
24108
|
+
function convertTrailingSlash(enable, status = 308) {
|
|
24109
|
+
const routes = [];
|
|
24110
|
+
if (enable) {
|
|
24111
|
+
routes.push({
|
|
24112
|
+
src: "^/\\.well-known(?:/.*)?$"
|
|
24113
|
+
});
|
|
24114
|
+
routes.push({
|
|
24115
|
+
src: "^/((?:[^/]+/)*[^/\\.]+)$",
|
|
24116
|
+
headers: { Location: "/$1/" },
|
|
24117
|
+
status
|
|
24118
|
+
});
|
|
24119
|
+
routes.push({
|
|
24120
|
+
src: "^/((?:[^/]+/)*[^/]+\\.\\w+)/$",
|
|
24121
|
+
headers: { Location: "/$1" },
|
|
24122
|
+
status
|
|
24123
|
+
});
|
|
24124
|
+
} else {
|
|
24125
|
+
routes.push({
|
|
24126
|
+
src: "^/(.*)\\/$",
|
|
24127
|
+
headers: { Location: "/$1" },
|
|
24128
|
+
status
|
|
24129
|
+
});
|
|
24130
|
+
}
|
|
24131
|
+
return routes;
|
|
24132
|
+
}
|
|
24133
|
+
function sourceToRegex2(source) {
|
|
24134
|
+
const keys = [];
|
|
24135
|
+
const r = pathToRegexp3("632", source, keys, {
|
|
24136
|
+
strict: true,
|
|
24137
|
+
sensitive: true,
|
|
24138
|
+
delimiter: "/"
|
|
24139
|
+
});
|
|
24140
|
+
const segments = keys.map((k) => k.name).map((name) => {
|
|
24141
|
+
if (typeof name !== "string") {
|
|
24142
|
+
return UN_NAMED_SEGMENT;
|
|
24143
|
+
}
|
|
24144
|
+
return name;
|
|
24145
|
+
});
|
|
24146
|
+
return { src: r.source, segments };
|
|
24147
|
+
}
|
|
24148
|
+
var namedGroupsRegex = /\(\?<([a-zA-Z][a-zA-Z0-9_]*)>/g;
|
|
24149
|
+
var normalizeHasKeys = (hasItems = []) => {
|
|
24150
|
+
for (const hasItem of hasItems) {
|
|
24151
|
+
if ("key" in hasItem && hasItem.type === "header") {
|
|
24152
|
+
hasItem.key = hasItem.key.toLowerCase();
|
|
24153
|
+
}
|
|
24154
|
+
}
|
|
24155
|
+
return hasItems;
|
|
24156
|
+
};
|
|
24157
|
+
function getStringValueForRegex(value) {
|
|
24158
|
+
if (typeof value === "string") {
|
|
24159
|
+
return value;
|
|
24160
|
+
}
|
|
24161
|
+
if (value && typeof value === "object" && value !== null) {
|
|
24162
|
+
if ("re" in value && typeof value.re === "string") {
|
|
24163
|
+
return value.re;
|
|
24164
|
+
}
|
|
24165
|
+
}
|
|
24166
|
+
return null;
|
|
24167
|
+
}
|
|
24168
|
+
function collectHasSegments(has) {
|
|
24169
|
+
const hasSegments = /* @__PURE__ */ new Set();
|
|
24170
|
+
for (const hasItem of has || []) {
|
|
24171
|
+
if (!hasItem.value && "key" in hasItem) {
|
|
24172
|
+
hasSegments.add(hasItem.key);
|
|
24173
|
+
}
|
|
24174
|
+
const stringValue = getStringValueForRegex(hasItem.value);
|
|
24175
|
+
if (stringValue) {
|
|
24176
|
+
for (const match of stringValue.matchAll(namedGroupsRegex)) {
|
|
24177
|
+
if (match[1]) {
|
|
24178
|
+
hasSegments.add(match[1]);
|
|
24179
|
+
}
|
|
24180
|
+
}
|
|
24181
|
+
if (hasItem.type === "host") {
|
|
24182
|
+
hasSegments.add("host");
|
|
24183
|
+
}
|
|
24184
|
+
}
|
|
24185
|
+
}
|
|
24186
|
+
return [...hasSegments];
|
|
24187
|
+
}
|
|
24188
|
+
var escapeSegment = (str, segmentName) => str.replace(new RegExp(`:${segmentName}`, "g"), `__ESC_COLON_${segmentName}`);
|
|
24189
|
+
var unescapeSegments = (str) => str.replace(/__ESC_COLON_/gi, ":");
|
|
24190
|
+
var pathTemplateSegmentNameRegex = /^([a-zA-Z_][a-zA-Z0-9_]*)/;
|
|
24191
|
+
function isEscaped2(value, index) {
|
|
24192
|
+
let backslashCount = 0;
|
|
24193
|
+
for (let i = index - 1; i >= 0 && value[i] === "\\"; i--) {
|
|
24194
|
+
backslashCount++;
|
|
24195
|
+
}
|
|
24196
|
+
return backslashCount % 2 === 1;
|
|
24197
|
+
}
|
|
24198
|
+
function collectPathTemplateSegments(template) {
|
|
24199
|
+
const segments = [];
|
|
24200
|
+
for (let i = 0; i < template.length; i++) {
|
|
24201
|
+
if (template[i] !== ":" || isEscaped2(template, i)) {
|
|
24202
|
+
continue;
|
|
24203
|
+
}
|
|
24204
|
+
const match = template.slice(i + 1).match(pathTemplateSegmentNameRegex);
|
|
24205
|
+
if (match) {
|
|
24206
|
+
segments.push(match[1]);
|
|
24207
|
+
i += match[1].length;
|
|
24208
|
+
}
|
|
24209
|
+
}
|
|
24210
|
+
return segments;
|
|
24211
|
+
}
|
|
24212
|
+
function collectNamedDollarReferences(template) {
|
|
24213
|
+
const references = [];
|
|
24214
|
+
for (let i = 0; i < template.length; i++) {
|
|
24215
|
+
if (template[i] !== "$" || isEscaped2(template, i)) {
|
|
24216
|
+
continue;
|
|
24217
|
+
}
|
|
24218
|
+
const remainder = template.slice(i + 1);
|
|
24219
|
+
const bracedMatch = remainder.match(/^\{([a-zA-Z_][a-zA-Z0-9_]*)\}/);
|
|
24220
|
+
const unbracedMatch = remainder.match(pathTemplateSegmentNameRegex);
|
|
24221
|
+
const name = bracedMatch?.[1] || unbracedMatch?.[1];
|
|
24222
|
+
if (name) {
|
|
24223
|
+
references.push(name);
|
|
24224
|
+
}
|
|
24225
|
+
}
|
|
24226
|
+
return references;
|
|
24227
|
+
}
|
|
24228
|
+
function compilePathToRegexpTemplateFromSegments(template, segments, hasItemSegments, env = []) {
|
|
24229
|
+
const indexes = {};
|
|
24230
|
+
segments.forEach((name, index) => {
|
|
24231
|
+
indexes[name] = toSegmentDest(index);
|
|
24232
|
+
});
|
|
24233
|
+
hasItemSegments.forEach((name) => {
|
|
24234
|
+
indexes[name] = `$${name}`;
|
|
24235
|
+
});
|
|
24236
|
+
for (const name of collectPathTemplateSegments(template)) {
|
|
24237
|
+
if (!(name in indexes)) {
|
|
24238
|
+
throw new Error(
|
|
24239
|
+
`Path template references parameter ":${name}" that is not present in the source or has conditions.`
|
|
24240
|
+
);
|
|
24241
|
+
}
|
|
24242
|
+
}
|
|
24243
|
+
const routeParameters = /* @__PURE__ */ new Set([
|
|
24244
|
+
...segments.filter((name) => name !== UN_NAMED_SEGMENT),
|
|
24245
|
+
...hasItemSegments
|
|
24246
|
+
]);
|
|
24247
|
+
for (const name of collectNamedDollarReferences(template)) {
|
|
24248
|
+
if (routeParameters.has(name) && !env.includes(name)) {
|
|
24249
|
+
throw new Error(
|
|
24250
|
+
`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.`
|
|
24251
|
+
);
|
|
24252
|
+
}
|
|
24253
|
+
}
|
|
24254
|
+
return safelyCompile(template, indexes, true);
|
|
24255
|
+
}
|
|
24256
|
+
function compilePathToRegexpTemplate2(source, template, has, env) {
|
|
24257
|
+
const { segments } = sourceToRegex2(source);
|
|
24258
|
+
return compilePathToRegexpTemplateFromSegments(
|
|
24259
|
+
template,
|
|
24260
|
+
segments,
|
|
24261
|
+
collectHasSegments(has),
|
|
24262
|
+
env
|
|
24263
|
+
);
|
|
24264
|
+
}
|
|
24265
|
+
function replaceSegments(segments, hasItemSegments, destination, isRedirect, internalParamNames) {
|
|
24266
|
+
const namedSegments = segments.filter((name) => name !== UN_NAMED_SEGMENT);
|
|
24267
|
+
const canNeedReplacing = destination.includes(":") && namedSegments.length > 0 || hasItemSegments.length > 0 || !isRedirect;
|
|
24268
|
+
if (!canNeedReplacing) {
|
|
24269
|
+
return destination;
|
|
24270
|
+
}
|
|
24271
|
+
let escapedDestination = destination;
|
|
24272
|
+
const indexes = {};
|
|
24273
|
+
segments.forEach((name, index) => {
|
|
24274
|
+
indexes[name] = toSegmentDest(index);
|
|
24275
|
+
escapedDestination = escapeSegment(escapedDestination, name);
|
|
24276
|
+
});
|
|
24277
|
+
hasItemSegments.forEach((name) => {
|
|
24278
|
+
indexes[name] = "$" + name;
|
|
24279
|
+
escapedDestination = escapeSegment(escapedDestination, name);
|
|
24280
|
+
});
|
|
24281
|
+
const parsedDestination = (0, import_url.parse)(escapedDestination, true);
|
|
24282
|
+
delete parsedDestination.href;
|
|
24283
|
+
delete parsedDestination.path;
|
|
24284
|
+
delete parsedDestination.search;
|
|
24285
|
+
delete parsedDestination.host;
|
|
24286
|
+
let { pathname, hash, query, hostname, ...rest } = parsedDestination;
|
|
24287
|
+
pathname = unescapeSegments(pathname || "");
|
|
24288
|
+
hash = unescapeSegments(hash || "");
|
|
24289
|
+
hostname = unescapeSegments(hostname || "");
|
|
24290
|
+
let destParams = /* @__PURE__ */ new Set();
|
|
24291
|
+
const pathnameKeys = [];
|
|
24292
|
+
const hashKeys = [];
|
|
24293
|
+
const hostnameKeys = [];
|
|
24294
|
+
try {
|
|
24295
|
+
pathToRegexp3("528", pathname, pathnameKeys);
|
|
24296
|
+
pathToRegexp3("834", hash || "", hashKeys);
|
|
24297
|
+
pathToRegexp3("712", hostname || "", hostnameKeys);
|
|
24298
|
+
} catch (_) {
|
|
24299
|
+
}
|
|
24300
|
+
destParams = new Set(
|
|
24301
|
+
[...pathnameKeys, ...hashKeys, ...hostnameKeys].map((key) => key.name).filter((val) => typeof val === "string")
|
|
24302
|
+
);
|
|
24303
|
+
pathname = safelyCompile(pathname, indexes, true);
|
|
24304
|
+
hash = hash ? safelyCompile(hash, indexes, true) : null;
|
|
24305
|
+
hostname = hostname ? safelyCompile(hostname, indexes, true) : null;
|
|
24306
|
+
for (const [key, strOrArray] of Object.entries(query)) {
|
|
24307
|
+
if (Array.isArray(strOrArray)) {
|
|
24308
|
+
query[key] = strOrArray.map(
|
|
24309
|
+
(str) => safelyCompile(unescapeSegments(str), indexes, true)
|
|
24310
|
+
);
|
|
24311
|
+
} else {
|
|
24312
|
+
query[key] = safelyCompile(
|
|
24313
|
+
unescapeSegments(strOrArray),
|
|
24314
|
+
indexes,
|
|
24315
|
+
true
|
|
24316
|
+
);
|
|
24317
|
+
}
|
|
24318
|
+
}
|
|
24319
|
+
const paramKeys = Object.keys(indexes);
|
|
24320
|
+
const needsQueryUpdating = (
|
|
24321
|
+
// we do not consider an internal param since it is added automatically
|
|
24322
|
+
!isRedirect && !paramKeys.some(
|
|
24323
|
+
(param) => !(internalParamNames && internalParamNames.includes(param)) && destParams.has(param)
|
|
24324
|
+
)
|
|
24325
|
+
);
|
|
24326
|
+
if (needsQueryUpdating) {
|
|
24327
|
+
for (const param of paramKeys) {
|
|
24328
|
+
if (!(param in query) && param !== UN_NAMED_SEGMENT) {
|
|
24329
|
+
query[param] = indexes[param];
|
|
24330
|
+
}
|
|
24331
|
+
}
|
|
24332
|
+
}
|
|
24333
|
+
destination = (0, import_url.format)({
|
|
24334
|
+
...rest,
|
|
24335
|
+
hostname,
|
|
24336
|
+
pathname,
|
|
24337
|
+
query,
|
|
24338
|
+
hash
|
|
24339
|
+
});
|
|
24340
|
+
return destination.replace(/%24/g, "$");
|
|
24341
|
+
}
|
|
24342
|
+
function safelyCompile(value, indexes, attemptDirectCompile) {
|
|
24343
|
+
if (!value) {
|
|
24344
|
+
return value;
|
|
24345
|
+
}
|
|
24346
|
+
if (attemptDirectCompile) {
|
|
24347
|
+
try {
|
|
24348
|
+
return (0, import_path_to_regexp.compile)(value, { validate: false })(indexes);
|
|
24349
|
+
} catch (_e) {
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
for (const key of Object.keys(indexes)) {
|
|
24353
|
+
if (value.includes(`:${key}`)) {
|
|
24354
|
+
value = value.replace(
|
|
24355
|
+
new RegExp(`:${key}\\*`, "g"),
|
|
24356
|
+
`:${key}--ESCAPED_PARAM_ASTERISK`
|
|
24357
|
+
).replace(
|
|
24358
|
+
new RegExp(`:${key}\\?`, "g"),
|
|
24359
|
+
`:${key}--ESCAPED_PARAM_QUESTION`
|
|
24360
|
+
).replace(new RegExp(`:${key}\\+`, "g"), `:${key}--ESCAPED_PARAM_PLUS`).replace(
|
|
24361
|
+
new RegExp(`:${key}(?!\\w)`, "g"),
|
|
24362
|
+
`--ESCAPED_PARAM_COLON${key}`
|
|
24363
|
+
);
|
|
24364
|
+
}
|
|
24365
|
+
}
|
|
24366
|
+
value = value.replace(/(:|\*|\?|\+|\(|\)|\{|\})/g, "\\$1").replace(/--ESCAPED_PARAM_PLUS/g, "+").replace(/--ESCAPED_PARAM_COLON/g, ":").replace(/--ESCAPED_PARAM_QUESTION/g, "?").replace(/--ESCAPED_PARAM_ASTERISK/g, "*");
|
|
24367
|
+
return (0, import_path_to_regexp.compile)(`/${value}`, { validate: false })(indexes).slice(1);
|
|
24368
|
+
}
|
|
24369
|
+
function toSegmentDest(index) {
|
|
24370
|
+
const i = index + 1;
|
|
24371
|
+
return "$" + i.toString();
|
|
24372
|
+
}
|
|
24373
|
+
function toRoute(filePath) {
|
|
24374
|
+
return filePath.startsWith("/") ? filePath : "/" + filePath;
|
|
24375
|
+
}
|
|
24376
|
+
}
|
|
24377
|
+
});
|
|
24378
|
+
|
|
24379
|
+
// ../routing-utils/dist/append.js
|
|
24380
|
+
var require_append = __commonJS({
|
|
24381
|
+
"../routing-utils/dist/append.js"(exports, module2) {
|
|
24382
|
+
"use strict";
|
|
24383
|
+
var __defProp2 = Object.defineProperty;
|
|
24384
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
24385
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
24386
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
24387
|
+
var __export2 = (target, all) => {
|
|
24388
|
+
for (var name in all)
|
|
24389
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
24390
|
+
};
|
|
24391
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
24392
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24393
|
+
for (let key of __getOwnPropNames2(from))
|
|
24394
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
24395
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
24396
|
+
}
|
|
24397
|
+
return to;
|
|
24398
|
+
};
|
|
24399
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
24400
|
+
var append_exports = {};
|
|
24401
|
+
__export2(append_exports, {
|
|
24402
|
+
appendRoutesToPhase: () => appendRoutesToPhase2
|
|
24403
|
+
});
|
|
24404
|
+
module2.exports = __toCommonJS2(append_exports);
|
|
24405
|
+
var import_index = require_dist4();
|
|
24406
|
+
function appendRoutesToPhase2({
|
|
24407
|
+
routes: prevRoutes,
|
|
24408
|
+
newRoutes,
|
|
24409
|
+
phase
|
|
24410
|
+
}) {
|
|
24411
|
+
const routes = prevRoutes ? [...prevRoutes] : [];
|
|
24412
|
+
if (newRoutes === null || newRoutes.length === 0) {
|
|
24413
|
+
return routes;
|
|
24414
|
+
}
|
|
24415
|
+
let isInPhase = false;
|
|
24416
|
+
let insertIndex = -1;
|
|
24417
|
+
routes.forEach((r, i) => {
|
|
24418
|
+
if ((0, import_index.isHandler)(r)) {
|
|
24419
|
+
if (r.handle === phase) {
|
|
24420
|
+
isInPhase = true;
|
|
24421
|
+
} else if (isInPhase) {
|
|
24422
|
+
insertIndex = i;
|
|
24423
|
+
isInPhase = false;
|
|
24424
|
+
}
|
|
24425
|
+
}
|
|
24426
|
+
});
|
|
24427
|
+
if (isInPhase) {
|
|
24428
|
+
routes.push(...newRoutes);
|
|
24429
|
+
} else if (phase === null) {
|
|
24430
|
+
const lastPhase = routes.findIndex((r) => (0, import_index.isHandler)(r) && r.handle);
|
|
24431
|
+
if (lastPhase === -1) {
|
|
24432
|
+
routes.push(...newRoutes);
|
|
24433
|
+
} else {
|
|
24434
|
+
routes.splice(lastPhase, 0, ...newRoutes);
|
|
24435
|
+
}
|
|
24436
|
+
} else if (insertIndex > -1) {
|
|
24437
|
+
routes.splice(insertIndex, 0, ...newRoutes);
|
|
24438
|
+
} else {
|
|
24439
|
+
routes.push({ handle: phase });
|
|
24440
|
+
routes.push(...newRoutes);
|
|
24441
|
+
}
|
|
24442
|
+
return routes;
|
|
24443
|
+
}
|
|
24444
|
+
}
|
|
24445
|
+
});
|
|
24446
|
+
|
|
24447
|
+
// ../routing-utils/dist/merge.js
|
|
24448
|
+
var require_merge2 = __commonJS({
|
|
24449
|
+
"../routing-utils/dist/merge.js"(exports, module2) {
|
|
24450
|
+
"use strict";
|
|
24451
|
+
var __defProp2 = Object.defineProperty;
|
|
24452
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
24453
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
24454
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
24455
|
+
var __export2 = (target, all) => {
|
|
24456
|
+
for (var name in all)
|
|
24457
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
24458
|
+
};
|
|
24459
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
24460
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24461
|
+
for (let key of __getOwnPropNames2(from))
|
|
24462
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
24463
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
24464
|
+
}
|
|
24465
|
+
return to;
|
|
24466
|
+
};
|
|
24467
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
24468
|
+
var merge_exports = {};
|
|
24469
|
+
__export2(merge_exports, {
|
|
24470
|
+
mergeRoutes: () => mergeRoutes2
|
|
24471
|
+
});
|
|
24472
|
+
module2.exports = __toCommonJS2(merge_exports);
|
|
24473
|
+
var import_index = require_dist4();
|
|
24474
|
+
function getBuilderRoutesMapping(builds) {
|
|
24475
|
+
const builderRoutes = {};
|
|
24476
|
+
for (const { entrypoint, routes, use } of builds) {
|
|
24477
|
+
if (routes) {
|
|
24478
|
+
if (!builderRoutes[entrypoint]) {
|
|
24479
|
+
builderRoutes[entrypoint] = {};
|
|
24480
|
+
}
|
|
24481
|
+
builderRoutes[entrypoint][use] = routes;
|
|
24482
|
+
}
|
|
24483
|
+
}
|
|
24484
|
+
return builderRoutes;
|
|
24485
|
+
}
|
|
24486
|
+
function getCheckAndContinue(routes) {
|
|
24487
|
+
const checks = [];
|
|
24488
|
+
const continues = [];
|
|
24489
|
+
const others = [];
|
|
24490
|
+
for (const route of routes) {
|
|
24491
|
+
if ((0, import_index.isHandler)(route)) {
|
|
24492
|
+
throw new Error(
|
|
24493
|
+
`Unexpected route found in getCheckAndContinue(): ${JSON.stringify(
|
|
24494
|
+
route
|
|
24495
|
+
)}`
|
|
24496
|
+
);
|
|
24497
|
+
} else if (route.check && !route.override) {
|
|
24498
|
+
checks.push(route);
|
|
24499
|
+
} else if (route.continue && !route.override) {
|
|
24500
|
+
continues.push(route);
|
|
24501
|
+
} else {
|
|
24502
|
+
others.push(route);
|
|
24503
|
+
}
|
|
24504
|
+
}
|
|
24505
|
+
return { checks, continues, others };
|
|
24506
|
+
}
|
|
24507
|
+
function mergeRoutes2({ userRoutes, builds }) {
|
|
24508
|
+
const userHandleMap = /* @__PURE__ */ new Map();
|
|
24509
|
+
let userPrevHandle = null;
|
|
24510
|
+
(userRoutes || []).forEach((route) => {
|
|
24511
|
+
if ((0, import_index.isHandler)(route)) {
|
|
24512
|
+
userPrevHandle = route.handle;
|
|
24513
|
+
} else {
|
|
24514
|
+
const routes = userHandleMap.get(userPrevHandle);
|
|
24515
|
+
if (!routes) {
|
|
24516
|
+
userHandleMap.set(userPrevHandle, [route]);
|
|
24517
|
+
} else {
|
|
24518
|
+
routes.push(route);
|
|
24519
|
+
}
|
|
24520
|
+
}
|
|
24521
|
+
});
|
|
24522
|
+
const builderHandleMap = /* @__PURE__ */ new Map();
|
|
24523
|
+
const builderRoutes = getBuilderRoutesMapping(builds);
|
|
24524
|
+
const sortedPaths = Object.keys(builderRoutes).sort();
|
|
24525
|
+
sortedPaths.forEach((path8) => {
|
|
24526
|
+
const br = builderRoutes[path8];
|
|
24527
|
+
const sortedBuilders = Object.keys(br).sort();
|
|
24528
|
+
sortedBuilders.forEach((use) => {
|
|
24529
|
+
let builderPrevHandle = null;
|
|
24530
|
+
br[use].forEach((route) => {
|
|
24531
|
+
if ((0, import_index.isHandler)(route)) {
|
|
24532
|
+
builderPrevHandle = route.handle;
|
|
24533
|
+
} else {
|
|
24534
|
+
const routes = builderHandleMap.get(builderPrevHandle);
|
|
24535
|
+
if (!routes) {
|
|
24536
|
+
builderHandleMap.set(builderPrevHandle, [route]);
|
|
24537
|
+
} else {
|
|
24538
|
+
routes.push(route);
|
|
24539
|
+
}
|
|
24540
|
+
}
|
|
24541
|
+
});
|
|
24542
|
+
});
|
|
24543
|
+
});
|
|
24544
|
+
const outputRoutes = [];
|
|
24545
|
+
const uniqueHandleValues = /* @__PURE__ */ new Set([
|
|
24546
|
+
null,
|
|
24547
|
+
...userHandleMap.keys(),
|
|
24548
|
+
...builderHandleMap.keys()
|
|
24549
|
+
]);
|
|
24550
|
+
for (const handle of uniqueHandleValues) {
|
|
24551
|
+
const userRoutes2 = userHandleMap.get(handle) || [];
|
|
24552
|
+
const builderRoutes2 = builderHandleMap.get(handle) || [];
|
|
24553
|
+
const builderSorted = getCheckAndContinue(builderRoutes2);
|
|
24554
|
+
if (handle !== null && (userRoutes2.length > 0 || builderRoutes2.length > 0)) {
|
|
24555
|
+
outputRoutes.push({ handle });
|
|
24556
|
+
}
|
|
24557
|
+
outputRoutes.push(...builderSorted.continues);
|
|
24558
|
+
outputRoutes.push(...userRoutes2);
|
|
24559
|
+
outputRoutes.push(...builderSorted.checks);
|
|
24560
|
+
outputRoutes.push(...builderSorted.others);
|
|
24561
|
+
}
|
|
24562
|
+
return outputRoutes;
|
|
24563
|
+
}
|
|
24564
|
+
}
|
|
24565
|
+
});
|
|
24566
|
+
|
|
24567
|
+
// ../routing-utils/dist/service-route-ownership.js
|
|
24568
|
+
var require_service_route_ownership = __commonJS({
|
|
24569
|
+
"../routing-utils/dist/service-route-ownership.js"(exports, module2) {
|
|
24570
|
+
"use strict";
|
|
24571
|
+
var __defProp2 = Object.defineProperty;
|
|
24572
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
24573
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
24574
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
24575
|
+
var __export2 = (target, all) => {
|
|
24576
|
+
for (var name in all)
|
|
24577
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
24578
|
+
};
|
|
24579
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
24580
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24581
|
+
for (let key of __getOwnPropNames2(from))
|
|
24582
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
24583
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
24584
|
+
}
|
|
24585
|
+
return to;
|
|
24586
|
+
};
|
|
24587
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
24588
|
+
var service_route_ownership_exports = {};
|
|
24589
|
+
__export2(service_route_ownership_exports, {
|
|
24590
|
+
getOwnershipGuard: () => getOwnershipGuard2,
|
|
24591
|
+
normalizeRoutePrefix: () => normalizeRoutePrefix2,
|
|
24592
|
+
scopeRouteSourceToOwnership: () => scopeRouteSourceToOwnership2
|
|
24593
|
+
});
|
|
24594
|
+
module2.exports = __toCommonJS2(service_route_ownership_exports);
|
|
24595
|
+
function normalizeRoutePrefix2(routePrefix) {
|
|
24596
|
+
let normalized = routePrefix.startsWith("/") ? routePrefix : `/${routePrefix}`;
|
|
24597
|
+
if (normalized !== "/" && normalized.endsWith("/")) {
|
|
24598
|
+
normalized = normalized.slice(0, -1);
|
|
24599
|
+
}
|
|
24600
|
+
return normalized || "/";
|
|
24601
|
+
}
|
|
24602
|
+
function escapeForRegex(value) {
|
|
24603
|
+
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
|
|
24604
|
+
}
|
|
24605
|
+
function toPrefixMatcher(routePrefix) {
|
|
24606
|
+
return `${escapeForRegex(routePrefix)}(?:/|$)`;
|
|
24607
|
+
}
|
|
24608
|
+
function isDescendantPrefix(candidate, prefix) {
|
|
24609
|
+
return candidate !== prefix && candidate.startsWith(`${prefix}/`);
|
|
24610
|
+
}
|
|
24611
|
+
function getOwnershipGuard2(ownerPrefix, allRoutePrefixes) {
|
|
24612
|
+
const owner = normalizeRoutePrefix2(ownerPrefix);
|
|
24613
|
+
const normalizedPrefixes = Array.from(
|
|
24614
|
+
new Set(allRoutePrefixes.map(normalizeRoutePrefix2))
|
|
24615
|
+
);
|
|
24616
|
+
const nonRootPrefixes = normalizedPrefixes.filter((prefix) => prefix !== "/").sort((a, b) => b.length - a.length);
|
|
24617
|
+
if (owner === "/") {
|
|
24618
|
+
return nonRootPrefixes.map((prefix) => `(?!${toPrefixMatcher(prefix)})`).join("");
|
|
24619
|
+
}
|
|
24620
|
+
const descendants = nonRootPrefixes.filter(
|
|
24621
|
+
(prefix) => isDescendantPrefix(prefix, owner)
|
|
24622
|
+
);
|
|
24623
|
+
const positive = `(?=${toPrefixMatcher(owner)})`;
|
|
24624
|
+
const negative = descendants.map((prefix) => `(?!${toPrefixMatcher(prefix)})`).join("");
|
|
24625
|
+
return `${positive}${negative}`;
|
|
24626
|
+
}
|
|
24627
|
+
function scopeRouteSourceToOwnership2(source, ownershipGuard) {
|
|
24628
|
+
if (!ownershipGuard) {
|
|
24629
|
+
return source;
|
|
24630
|
+
}
|
|
24631
|
+
const inner = source.startsWith("^") ? source.slice(1) : source;
|
|
24632
|
+
return `^${ownershipGuard}(?:${inner})`;
|
|
24633
|
+
}
|
|
24634
|
+
}
|
|
24635
|
+
});
|
|
24636
|
+
|
|
24637
|
+
// ../routing-utils/dist/schemas.js
|
|
24638
|
+
var require_schemas = __commonJS({
|
|
24639
|
+
"../routing-utils/dist/schemas.js"(exports, module2) {
|
|
24640
|
+
"use strict";
|
|
24641
|
+
var __defProp2 = Object.defineProperty;
|
|
24642
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
24643
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
24644
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
24645
|
+
var __export2 = (target, all) => {
|
|
24646
|
+
for (var name in all)
|
|
24647
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
24648
|
+
};
|
|
24649
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
24650
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24651
|
+
for (let key of __getOwnPropNames2(from))
|
|
24652
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
24653
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
24654
|
+
}
|
|
24655
|
+
return to;
|
|
24656
|
+
};
|
|
24657
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
24658
|
+
var schemas_exports = {};
|
|
24659
|
+
__export2(schemas_exports, {
|
|
24660
|
+
cleanUrlsSchema: () => cleanUrlsSchema,
|
|
24661
|
+
hasSchema: () => hasSchema,
|
|
24662
|
+
headersSchema: () => headersSchema,
|
|
24663
|
+
redirectsSchema: () => redirectsSchema,
|
|
24664
|
+
rewritesSchema: () => rewritesSchema,
|
|
24665
|
+
routesSchema: () => routesSchema,
|
|
24666
|
+
trailingSlashSchema: () => trailingSlashSchema,
|
|
24667
|
+
transformsSchema: () => transformsSchema
|
|
24668
|
+
});
|
|
24669
|
+
module2.exports = __toCommonJS2(schemas_exports);
|
|
24670
|
+
var mitigateSchema = {
|
|
24671
|
+
description: "Mitigation action to take on a route",
|
|
24672
|
+
type: "object",
|
|
24673
|
+
additionalProperties: false,
|
|
24674
|
+
required: ["action"],
|
|
24675
|
+
properties: {
|
|
24676
|
+
action: {
|
|
24677
|
+
description: "The mitigation action to take",
|
|
24678
|
+
type: "string",
|
|
24679
|
+
enum: ["challenge", "deny"]
|
|
24680
|
+
}
|
|
24681
|
+
}
|
|
24682
|
+
};
|
|
24683
|
+
var serviceNameSchema = {
|
|
24684
|
+
description: "A service name identifier.",
|
|
24685
|
+
type: "string",
|
|
24686
|
+
minLength: 1,
|
|
24687
|
+
maxLength: 64,
|
|
24688
|
+
pattern: "^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$"
|
|
24689
|
+
};
|
|
24690
|
+
var serviceDestinationSchema = {
|
|
24691
|
+
description: "A service-targeted destination that delegates routing into a named service from `services`. Identified by the presence of `service`.",
|
|
24692
|
+
type: "object",
|
|
24693
|
+
additionalProperties: false,
|
|
24694
|
+
required: ["service"],
|
|
24695
|
+
properties: {
|
|
24696
|
+
type: {
|
|
24697
|
+
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`.",
|
|
24698
|
+
type: "string",
|
|
24699
|
+
enum: ["service"]
|
|
24700
|
+
},
|
|
24701
|
+
service: serviceNameSchema,
|
|
24702
|
+
path: {
|
|
24703
|
+
description: "Routing-only path used to select a route inside the target service. It does not mutate the URL observed by user code.",
|
|
24704
|
+
type: "string",
|
|
24705
|
+
maxLength: 4096
|
|
24706
|
+
}
|
|
24707
|
+
}
|
|
24708
|
+
};
|
|
24709
|
+
var matchableValueSchema = {
|
|
24710
|
+
description: "A value to match against. Can be a string (regex) or a condition operation object",
|
|
24711
|
+
anyOf: [
|
|
24712
|
+
{
|
|
24713
|
+
description: "A regular expression used to match thev value. Named groups can be used in the destination.",
|
|
24714
|
+
type: "string",
|
|
24715
|
+
maxLength: 4096
|
|
24716
|
+
},
|
|
24717
|
+
{
|
|
24718
|
+
description: "A condition operation object",
|
|
24719
|
+
type: "object",
|
|
24720
|
+
additionalProperties: false,
|
|
24721
|
+
minProperties: 1,
|
|
24722
|
+
properties: {
|
|
24723
|
+
eq: {
|
|
24724
|
+
description: "Equal to",
|
|
24725
|
+
anyOf: [
|
|
24726
|
+
{
|
|
24727
|
+
type: "string",
|
|
24728
|
+
maxLength: 4096
|
|
24729
|
+
},
|
|
24730
|
+
{
|
|
24731
|
+
type: "number"
|
|
24732
|
+
}
|
|
24733
|
+
]
|
|
24734
|
+
},
|
|
24735
|
+
neq: {
|
|
24736
|
+
description: "Not equal",
|
|
24737
|
+
type: "string",
|
|
24738
|
+
maxLength: 4096
|
|
24739
|
+
},
|
|
24740
|
+
inc: {
|
|
24741
|
+
description: "In array",
|
|
24742
|
+
type: "array",
|
|
24743
|
+
items: {
|
|
24744
|
+
type: "string",
|
|
24745
|
+
maxLength: 4096
|
|
24746
|
+
}
|
|
24747
|
+
},
|
|
24748
|
+
ninc: {
|
|
24749
|
+
description: "Not in array",
|
|
24750
|
+
type: "array",
|
|
24751
|
+
items: {
|
|
24752
|
+
type: "string",
|
|
24753
|
+
maxLength: 4096
|
|
24754
|
+
}
|
|
24755
|
+
},
|
|
24756
|
+
pre: {
|
|
24757
|
+
description: "Starts with",
|
|
24758
|
+
type: "string",
|
|
24759
|
+
maxLength: 4096
|
|
24760
|
+
},
|
|
24761
|
+
suf: {
|
|
24762
|
+
description: "Ends with",
|
|
24763
|
+
type: "string",
|
|
24764
|
+
maxLength: 4096
|
|
24765
|
+
},
|
|
24766
|
+
re: {
|
|
24767
|
+
description: "Regex",
|
|
24768
|
+
type: "string",
|
|
24769
|
+
maxLength: 4096
|
|
24770
|
+
},
|
|
24771
|
+
gt: {
|
|
24772
|
+
description: "Greater than",
|
|
24773
|
+
type: "number"
|
|
24774
|
+
},
|
|
24775
|
+
gte: {
|
|
24776
|
+
description: "Greater than or equal to",
|
|
24777
|
+
type: "number"
|
|
24778
|
+
},
|
|
24779
|
+
lt: {
|
|
24780
|
+
description: "Less than",
|
|
24781
|
+
type: "number"
|
|
24782
|
+
},
|
|
24783
|
+
lte: {
|
|
24784
|
+
description: "Less than or equal to",
|
|
24785
|
+
type: "number"
|
|
24786
|
+
}
|
|
24787
|
+
}
|
|
24788
|
+
}
|
|
24789
|
+
]
|
|
24790
|
+
};
|
|
24791
|
+
var hasSchema = {
|
|
24792
|
+
description: "An array of requirements that are needed to match",
|
|
24793
|
+
type: "array",
|
|
24794
|
+
maxItems: 16,
|
|
24795
|
+
items: {
|
|
24796
|
+
anyOf: [
|
|
24797
|
+
{
|
|
24798
|
+
type: "object",
|
|
24799
|
+
additionalProperties: false,
|
|
24800
|
+
required: ["type", "value"],
|
|
24801
|
+
properties: {
|
|
24802
|
+
type: {
|
|
24803
|
+
description: "The type of request element to check",
|
|
24804
|
+
type: "string",
|
|
24805
|
+
enum: ["host"]
|
|
24806
|
+
},
|
|
24807
|
+
value: matchableValueSchema
|
|
24808
|
+
}
|
|
24809
|
+
},
|
|
24810
|
+
{
|
|
24811
|
+
type: "object",
|
|
24812
|
+
additionalProperties: false,
|
|
24813
|
+
required: ["type", "key"],
|
|
24814
|
+
properties: {
|
|
24815
|
+
type: {
|
|
24816
|
+
description: "The type of request element to check",
|
|
24817
|
+
type: "string",
|
|
24818
|
+
enum: ["header", "cookie", "query"]
|
|
24819
|
+
},
|
|
24820
|
+
key: {
|
|
24821
|
+
description: "The name of the element contained in the particular type",
|
|
24822
|
+
type: "string",
|
|
24823
|
+
maxLength: 4096
|
|
24824
|
+
},
|
|
24825
|
+
value: matchableValueSchema
|
|
24826
|
+
}
|
|
24827
|
+
}
|
|
24828
|
+
]
|
|
24829
|
+
}
|
|
24830
|
+
};
|
|
24831
|
+
var transformsSchema = {
|
|
24832
|
+
description: "A list of transform rules to adjust a request path, request query parameters, or request/response headers",
|
|
24833
|
+
type: "array",
|
|
24834
|
+
minItems: 1,
|
|
24835
|
+
items: {
|
|
24836
|
+
type: "object",
|
|
24837
|
+
additionalProperties: false,
|
|
24838
|
+
required: ["type", "op"],
|
|
24839
|
+
properties: {
|
|
24840
|
+
type: {
|
|
24841
|
+
description: "The scope of the transform to apply",
|
|
24842
|
+
type: "string",
|
|
24843
|
+
enum: [
|
|
24844
|
+
"request.headers",
|
|
24845
|
+
"request.query",
|
|
24846
|
+
"response.headers",
|
|
24847
|
+
"request.path"
|
|
24848
|
+
]
|
|
24849
|
+
},
|
|
24850
|
+
op: {
|
|
24851
|
+
description: "The operation to perform on the target",
|
|
24852
|
+
type: "string",
|
|
24853
|
+
enum: ["append", "set", "delete"]
|
|
24854
|
+
},
|
|
24855
|
+
target: {
|
|
24856
|
+
description: "The target of the transform",
|
|
24857
|
+
type: "object",
|
|
24858
|
+
required: ["key"],
|
|
24859
|
+
properties: {
|
|
24860
|
+
// re is not supported for transforms. Once supported, replace target.key with matchableValueSchema
|
|
24861
|
+
key: {
|
|
24862
|
+
description: "A value to match against. Can be a string or a condition operation object (without regex support)",
|
|
24863
|
+
anyOf: [
|
|
24864
|
+
{
|
|
24865
|
+
description: "A valid header name (letters, numbers, hyphens, underscores)",
|
|
24866
|
+
type: "string",
|
|
24867
|
+
maxLength: 4096
|
|
24868
|
+
},
|
|
24869
|
+
{
|
|
24870
|
+
description: "A condition operation object",
|
|
24871
|
+
type: "object",
|
|
24872
|
+
additionalProperties: false,
|
|
24873
|
+
minProperties: 1,
|
|
24874
|
+
properties: {
|
|
24875
|
+
eq: {
|
|
24876
|
+
description: "Equal to",
|
|
24877
|
+
anyOf: [
|
|
24878
|
+
{
|
|
24879
|
+
type: "string",
|
|
24880
|
+
maxLength: 4096
|
|
24881
|
+
},
|
|
24882
|
+
{
|
|
24883
|
+
type: "number"
|
|
24884
|
+
}
|
|
24885
|
+
]
|
|
24886
|
+
},
|
|
24887
|
+
neq: {
|
|
24888
|
+
description: "Not equal",
|
|
24889
|
+
type: "string",
|
|
24890
|
+
maxLength: 4096
|
|
24891
|
+
},
|
|
24892
|
+
inc: {
|
|
24893
|
+
description: "In array",
|
|
24894
|
+
type: "array",
|
|
24895
|
+
items: {
|
|
24896
|
+
type: "string",
|
|
24897
|
+
maxLength: 4096
|
|
24898
|
+
}
|
|
24899
|
+
},
|
|
24900
|
+
ninc: {
|
|
24901
|
+
description: "Not in array",
|
|
24902
|
+
type: "array",
|
|
24903
|
+
items: {
|
|
24904
|
+
type: "string",
|
|
24905
|
+
maxLength: 4096
|
|
24906
|
+
}
|
|
24907
|
+
},
|
|
24908
|
+
pre: {
|
|
24909
|
+
description: "Starts with",
|
|
24910
|
+
type: "string",
|
|
24911
|
+
maxLength: 4096
|
|
24912
|
+
},
|
|
24913
|
+
suf: {
|
|
24914
|
+
description: "Ends with",
|
|
24915
|
+
type: "string",
|
|
24916
|
+
maxLength: 4096
|
|
24917
|
+
},
|
|
24918
|
+
gt: {
|
|
24919
|
+
description: "Greater than",
|
|
24920
|
+
type: "number"
|
|
24921
|
+
},
|
|
24922
|
+
gte: {
|
|
24923
|
+
description: "Greater than or equal to",
|
|
24924
|
+
type: "number"
|
|
24925
|
+
},
|
|
24926
|
+
lt: {
|
|
24927
|
+
description: "Less than",
|
|
24928
|
+
type: "number"
|
|
24929
|
+
},
|
|
24930
|
+
lte: {
|
|
24931
|
+
description: "Less than or equal to",
|
|
24932
|
+
type: "number"
|
|
24933
|
+
}
|
|
24934
|
+
}
|
|
24935
|
+
}
|
|
24936
|
+
]
|
|
24937
|
+
}
|
|
24938
|
+
}
|
|
24939
|
+
},
|
|
24940
|
+
args: {
|
|
24941
|
+
description: "The arguments to the operation",
|
|
24942
|
+
anyOf: [
|
|
24943
|
+
{
|
|
24944
|
+
type: "string",
|
|
24945
|
+
maxLength: 4096
|
|
24946
|
+
},
|
|
24947
|
+
{
|
|
24948
|
+
type: "array",
|
|
24949
|
+
minItems: 1,
|
|
24950
|
+
items: {
|
|
24951
|
+
type: "string",
|
|
24952
|
+
maxLength: 4096
|
|
24953
|
+
}
|
|
24954
|
+
}
|
|
24955
|
+
]
|
|
24956
|
+
},
|
|
24957
|
+
env: {
|
|
24958
|
+
description: "An array of environment variable names that should be replaced at runtime in the args value",
|
|
24959
|
+
type: "array",
|
|
24960
|
+
minItems: 1,
|
|
24961
|
+
maxItems: 64,
|
|
24962
|
+
items: {
|
|
24963
|
+
type: "string",
|
|
24964
|
+
maxLength: 256
|
|
24965
|
+
}
|
|
24966
|
+
}
|
|
24967
|
+
},
|
|
24968
|
+
allOf: [
|
|
24969
|
+
{
|
|
24970
|
+
if: {
|
|
24971
|
+
properties: {
|
|
24972
|
+
op: {
|
|
24973
|
+
enum: ["append", "set"]
|
|
24974
|
+
}
|
|
24975
|
+
}
|
|
24976
|
+
},
|
|
24977
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
24978
|
+
then: {
|
|
24979
|
+
required: ["args"]
|
|
24980
|
+
}
|
|
24981
|
+
},
|
|
24982
|
+
{
|
|
24983
|
+
if: {
|
|
24984
|
+
allOf: [
|
|
24985
|
+
{
|
|
24986
|
+
properties: {
|
|
24987
|
+
type: {
|
|
24988
|
+
enum: ["request.headers", "response.headers"]
|
|
24989
|
+
}
|
|
24990
|
+
}
|
|
24991
|
+
},
|
|
24992
|
+
{
|
|
24993
|
+
properties: {
|
|
24994
|
+
op: {
|
|
24995
|
+
enum: ["set", "append"]
|
|
24996
|
+
}
|
|
24997
|
+
}
|
|
24998
|
+
}
|
|
24999
|
+
]
|
|
25000
|
+
},
|
|
25001
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
25002
|
+
then: {
|
|
25003
|
+
properties: {
|
|
25004
|
+
target: {
|
|
25005
|
+
properties: {
|
|
25006
|
+
key: {
|
|
25007
|
+
if: {
|
|
25008
|
+
type: "string"
|
|
25009
|
+
},
|
|
25010
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
25011
|
+
then: {
|
|
25012
|
+
pattern: "^[a-zA-Z0-9_-]+$"
|
|
25013
|
+
}
|
|
25014
|
+
}
|
|
25015
|
+
}
|
|
25016
|
+
},
|
|
25017
|
+
args: {
|
|
25018
|
+
anyOf: [
|
|
25019
|
+
{
|
|
25020
|
+
type: "string",
|
|
25021
|
+
pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$"
|
|
25022
|
+
},
|
|
25023
|
+
{
|
|
25024
|
+
type: "array",
|
|
25025
|
+
items: {
|
|
25026
|
+
type: "string",
|
|
25027
|
+
pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$"
|
|
25028
|
+
}
|
|
25029
|
+
}
|
|
25030
|
+
]
|
|
25031
|
+
}
|
|
25032
|
+
}
|
|
25033
|
+
}
|
|
25034
|
+
},
|
|
25035
|
+
{
|
|
25036
|
+
if: {
|
|
25037
|
+
required: ["type"],
|
|
25038
|
+
properties: {
|
|
25039
|
+
type: {
|
|
25040
|
+
enum: ["request.headers", "request.query", "response.headers"]
|
|
25041
|
+
}
|
|
25042
|
+
}
|
|
25043
|
+
},
|
|
25044
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
25045
|
+
then: {
|
|
25046
|
+
required: ["target"]
|
|
25047
|
+
}
|
|
25048
|
+
},
|
|
25049
|
+
{
|
|
25050
|
+
if: {
|
|
25051
|
+
required: ["type"],
|
|
25052
|
+
properties: {
|
|
25053
|
+
type: {
|
|
25054
|
+
enum: ["request.path"]
|
|
25055
|
+
}
|
|
25056
|
+
}
|
|
25057
|
+
},
|
|
25058
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
25059
|
+
then: {
|
|
25060
|
+
required: ["args"],
|
|
25061
|
+
not: {
|
|
25062
|
+
required: ["target"]
|
|
25063
|
+
},
|
|
25064
|
+
properties: {
|
|
25065
|
+
op: {
|
|
25066
|
+
enum: ["set"]
|
|
25067
|
+
},
|
|
25068
|
+
args: {
|
|
25069
|
+
description: "The runtime-visible request path. Must be an origin-form path without query or fragment.",
|
|
25070
|
+
type: "string",
|
|
25071
|
+
maxLength: 2048,
|
|
25072
|
+
pattern: "^/(?!/)(?!.*[?#\\s\\x00-\\x1F\\x7F]).*$"
|
|
25073
|
+
}
|
|
25074
|
+
}
|
|
25075
|
+
}
|
|
25076
|
+
}
|
|
25077
|
+
]
|
|
25078
|
+
}
|
|
25079
|
+
};
|
|
25080
|
+
var rewriteTransformsSchema = {
|
|
25081
|
+
description: "A list of request path transforms using path-to-regexp parameters.",
|
|
25082
|
+
type: "array",
|
|
25083
|
+
minItems: 1,
|
|
25084
|
+
items: {
|
|
25085
|
+
type: "object",
|
|
25086
|
+
additionalProperties: false,
|
|
25087
|
+
required: ["type", "op", "args"],
|
|
25088
|
+
properties: {
|
|
25089
|
+
type: {
|
|
25090
|
+
description: "The request path to expose to the target runtime",
|
|
25091
|
+
type: "string",
|
|
25092
|
+
enum: ["request.path"]
|
|
25093
|
+
},
|
|
25094
|
+
op: {
|
|
25095
|
+
description: "Replace the runtime-visible request path",
|
|
25096
|
+
type: "string",
|
|
25097
|
+
enum: ["set"]
|
|
25098
|
+
},
|
|
25099
|
+
args: {
|
|
25100
|
+
description: "An origin-form request path. Route parameters use path-to-regexp syntax such as `/:path*`.",
|
|
25101
|
+
type: "string",
|
|
25102
|
+
maxLength: 2048,
|
|
25103
|
+
pattern: "^/(?!/)(?!.*[?#\\s\\x00-\\x1F\\x7F]).*$"
|
|
25104
|
+
},
|
|
25105
|
+
env: {
|
|
25106
|
+
description: "An array of environment variable names that should be replaced at runtime in the args value",
|
|
25107
|
+
type: "array",
|
|
25108
|
+
minItems: 1,
|
|
25109
|
+
maxItems: 64,
|
|
25110
|
+
items: {
|
|
25111
|
+
type: "string",
|
|
25112
|
+
maxLength: 256
|
|
25113
|
+
}
|
|
25114
|
+
}
|
|
25115
|
+
}
|
|
25116
|
+
}
|
|
25117
|
+
};
|
|
25118
|
+
var routesSchema = {
|
|
25119
|
+
type: "array",
|
|
25120
|
+
description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
|
|
25121
|
+
example: [{ dest: "https://docs.example.com", src: "/docs" }],
|
|
25122
|
+
items: {
|
|
25123
|
+
anyOf: [
|
|
25124
|
+
{
|
|
25125
|
+
type: "object",
|
|
25126
|
+
anyOf: [{ required: ["src"] }, { required: ["source"] }],
|
|
25127
|
+
additionalProperties: false,
|
|
25128
|
+
properties: {
|
|
25129
|
+
src: {
|
|
25130
|
+
type: "string",
|
|
25131
|
+
maxLength: 4096
|
|
25132
|
+
},
|
|
25133
|
+
source: {
|
|
25134
|
+
type: "string",
|
|
25135
|
+
maxLength: 4096
|
|
25136
|
+
},
|
|
25137
|
+
dest: {
|
|
25138
|
+
type: "string",
|
|
25139
|
+
maxLength: 4096
|
|
25140
|
+
},
|
|
25141
|
+
destination: {
|
|
25142
|
+
anyOf: [
|
|
25143
|
+
{ type: "string", maxLength: 4096 },
|
|
25144
|
+
serviceDestinationSchema
|
|
25145
|
+
]
|
|
25146
|
+
},
|
|
25147
|
+
headers: {
|
|
25148
|
+
type: "object",
|
|
25149
|
+
additionalProperties: false,
|
|
25150
|
+
minProperties: 1,
|
|
25151
|
+
maxProperties: 100,
|
|
25152
|
+
patternProperties: {
|
|
25153
|
+
"^.{1,256}$": {
|
|
25154
|
+
type: "string",
|
|
25155
|
+
maxLength: 32768
|
|
25156
|
+
}
|
|
25157
|
+
}
|
|
25158
|
+
},
|
|
25159
|
+
methods: {
|
|
25160
|
+
type: "array",
|
|
25161
|
+
maxItems: 10,
|
|
25162
|
+
items: {
|
|
25163
|
+
type: "string",
|
|
25164
|
+
maxLength: 32
|
|
25165
|
+
}
|
|
25166
|
+
},
|
|
25167
|
+
caseSensitive: {
|
|
25168
|
+
type: "boolean"
|
|
25169
|
+
},
|
|
25170
|
+
important: {
|
|
25171
|
+
deprecated: true,
|
|
25172
|
+
type: "boolean"
|
|
25173
|
+
},
|
|
25174
|
+
user: {
|
|
25175
|
+
type: "boolean"
|
|
25176
|
+
},
|
|
25177
|
+
continue: {
|
|
25178
|
+
type: "boolean"
|
|
25179
|
+
},
|
|
25180
|
+
override: {
|
|
25181
|
+
deprecated: true,
|
|
25182
|
+
type: "boolean"
|
|
25183
|
+
},
|
|
25184
|
+
check: {
|
|
25185
|
+
type: "boolean"
|
|
25186
|
+
},
|
|
25187
|
+
isInternal: {
|
|
25188
|
+
type: "boolean"
|
|
25189
|
+
},
|
|
25190
|
+
status: {
|
|
25191
|
+
type: "integer",
|
|
25192
|
+
minimum: 100,
|
|
25193
|
+
maximum: 999
|
|
25194
|
+
},
|
|
25195
|
+
statusCode: {
|
|
25196
|
+
type: "integer",
|
|
25197
|
+
minimum: 100,
|
|
25198
|
+
maximum: 999
|
|
25199
|
+
},
|
|
25200
|
+
locale: {
|
|
25201
|
+
type: "object",
|
|
25202
|
+
additionalProperties: false,
|
|
25203
|
+
minProperties: 1,
|
|
25204
|
+
properties: {
|
|
25205
|
+
redirect: {
|
|
25206
|
+
type: "object",
|
|
25207
|
+
additionalProperties: false,
|
|
25208
|
+
minProperties: 1,
|
|
25209
|
+
maxProperties: 100,
|
|
25210
|
+
patternProperties: {
|
|
25211
|
+
"^.{1,256}$": {
|
|
25212
|
+
type: "string",
|
|
25213
|
+
maxLength: 4096
|
|
25214
|
+
}
|
|
25215
|
+
}
|
|
25216
|
+
},
|
|
25217
|
+
value: {
|
|
25218
|
+
type: "string",
|
|
25219
|
+
maxLength: 4096
|
|
25220
|
+
},
|
|
25221
|
+
path: {
|
|
25222
|
+
type: "string",
|
|
25223
|
+
maxLength: 4096
|
|
25224
|
+
},
|
|
25225
|
+
cookie: {
|
|
25226
|
+
type: "string",
|
|
25227
|
+
maxLength: 4096
|
|
25228
|
+
},
|
|
25229
|
+
default: {
|
|
25230
|
+
type: "string",
|
|
25231
|
+
maxLength: 4096
|
|
25232
|
+
}
|
|
25233
|
+
}
|
|
25234
|
+
},
|
|
25235
|
+
middleware: { type: "number" },
|
|
25236
|
+
middlewarePath: { type: "string" },
|
|
25237
|
+
middlewareRawSrc: {
|
|
25238
|
+
type: "array",
|
|
25239
|
+
items: {
|
|
25240
|
+
type: "string"
|
|
25241
|
+
}
|
|
25242
|
+
},
|
|
25243
|
+
has: hasSchema,
|
|
25244
|
+
missing: hasSchema,
|
|
25245
|
+
mitigate: mitigateSchema,
|
|
25246
|
+
transforms: transformsSchema,
|
|
25247
|
+
env: {
|
|
25248
|
+
description: "An array of environment variable names that should be replaced at runtime in the destination or headers",
|
|
25249
|
+
type: "array",
|
|
25250
|
+
minItems: 1,
|
|
25251
|
+
maxItems: 64,
|
|
25252
|
+
items: {
|
|
25253
|
+
type: "string",
|
|
25254
|
+
maxLength: 256
|
|
25255
|
+
}
|
|
25256
|
+
},
|
|
25257
|
+
respectOriginCacheControl: {
|
|
25258
|
+
description: "When set to true (default), external rewrites will respect the Cache-Control header from the origin. When false, caching is disabled for this rewrite.",
|
|
25259
|
+
type: "boolean"
|
|
25260
|
+
}
|
|
25261
|
+
}
|
|
25262
|
+
},
|
|
25263
|
+
{
|
|
25264
|
+
type: "object",
|
|
25265
|
+
deprecated: true,
|
|
25266
|
+
required: ["handle"],
|
|
25267
|
+
additionalProperties: false,
|
|
25268
|
+
properties: {
|
|
25269
|
+
handle: {
|
|
25270
|
+
type: "string",
|
|
25271
|
+
maxLength: 32,
|
|
25272
|
+
enum: ["error", "filesystem", "hit", "miss", "resource", "rewrite"]
|
|
25273
|
+
}
|
|
25274
|
+
}
|
|
25275
|
+
}
|
|
25276
|
+
]
|
|
25277
|
+
}
|
|
25278
|
+
};
|
|
25279
|
+
var rewritesSchema = {
|
|
25280
|
+
type: "array",
|
|
25281
|
+
maxItems: 2048,
|
|
25282
|
+
description: "A list of rewrite definitions.",
|
|
25283
|
+
items: {
|
|
25284
|
+
type: "object",
|
|
25285
|
+
additionalProperties: false,
|
|
25286
|
+
required: ["source", "destination"],
|
|
25287
|
+
properties: {
|
|
25288
|
+
source: {
|
|
25289
|
+
description: "A pattern that matches each incoming pathname (excluding querystring).",
|
|
25290
|
+
type: "string",
|
|
25291
|
+
maxLength: 4096
|
|
25292
|
+
},
|
|
25293
|
+
destination: {
|
|
25294
|
+
description: "An absolute pathname to an existing resource, an external URL, or a service-targeted destination object.",
|
|
25295
|
+
anyOf: [{ type: "string", maxLength: 4096 }, serviceDestinationSchema]
|
|
25296
|
+
},
|
|
25297
|
+
transforms: rewriteTransformsSchema,
|
|
25298
|
+
has: hasSchema,
|
|
25299
|
+
missing: hasSchema,
|
|
25300
|
+
statusCode: {
|
|
25301
|
+
description: "An optional integer to override the status code of the response.",
|
|
25302
|
+
type: "integer",
|
|
25303
|
+
minimum: 100,
|
|
25304
|
+
maximum: 999
|
|
25305
|
+
},
|
|
25306
|
+
env: {
|
|
25307
|
+
description: "An array of environment variable names that should be replaced at runtime in the destination",
|
|
25308
|
+
type: "array",
|
|
25309
|
+
minItems: 1,
|
|
25310
|
+
maxItems: 64,
|
|
25311
|
+
items: {
|
|
25312
|
+
type: "string",
|
|
25313
|
+
maxLength: 256
|
|
25314
|
+
}
|
|
25315
|
+
},
|
|
25316
|
+
respectOriginCacheControl: {
|
|
25317
|
+
description: "When set to true (default), external rewrites will respect the Cache-Control header from the origin. When false, caching is disabled for this rewrite.",
|
|
25318
|
+
type: "boolean"
|
|
25319
|
+
}
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
25322
|
+
};
|
|
25323
|
+
var redirectsSchema = {
|
|
25324
|
+
title: "Redirects",
|
|
25325
|
+
type: "array",
|
|
25326
|
+
maxItems: 2048,
|
|
25327
|
+
description: "A list of redirect definitions.",
|
|
25328
|
+
items: {
|
|
25329
|
+
type: "object",
|
|
25330
|
+
additionalProperties: false,
|
|
25331
|
+
required: ["source", "destination"],
|
|
25332
|
+
properties: {
|
|
25333
|
+
source: {
|
|
25334
|
+
description: "A pattern that matches each incoming pathname (excluding querystring) or a full URL including domain.",
|
|
25335
|
+
type: "string",
|
|
25336
|
+
maxLength: 4096
|
|
25337
|
+
},
|
|
25338
|
+
destination: {
|
|
25339
|
+
description: "A location destination defined as an absolute pathname or external URL.",
|
|
25340
|
+
type: "string",
|
|
25341
|
+
maxLength: 4096
|
|
25342
|
+
},
|
|
25343
|
+
permanent: {
|
|
25344
|
+
description: "A boolean to toggle between permanent and temporary redirect. When `true`, the status code is `308`. When `false` the status code is `307`.",
|
|
25345
|
+
type: "boolean"
|
|
25346
|
+
},
|
|
25347
|
+
statusCode: {
|
|
25348
|
+
description: "An optional integer to define the status code of the redirect.",
|
|
25349
|
+
private: true,
|
|
25350
|
+
type: "integer",
|
|
25351
|
+
minimum: 100,
|
|
25352
|
+
maximum: 999
|
|
25353
|
+
},
|
|
25354
|
+
has: hasSchema,
|
|
25355
|
+
missing: hasSchema,
|
|
25356
|
+
env: {
|
|
25357
|
+
description: "An array of environment variable names that should be replaced at runtime in the destination",
|
|
25358
|
+
type: "array",
|
|
25359
|
+
minItems: 1,
|
|
25360
|
+
maxItems: 64,
|
|
25361
|
+
items: {
|
|
25362
|
+
type: "string",
|
|
25363
|
+
maxLength: 256
|
|
25364
|
+
}
|
|
25365
|
+
}
|
|
25366
|
+
}
|
|
25367
|
+
}
|
|
25368
|
+
};
|
|
25369
|
+
var headersSchema = {
|
|
25370
|
+
type: "array",
|
|
25371
|
+
maxItems: 2048,
|
|
25372
|
+
description: "A list of header definitions.",
|
|
25373
|
+
items: {
|
|
25374
|
+
type: "object",
|
|
25375
|
+
additionalProperties: false,
|
|
25376
|
+
required: ["source", "headers"],
|
|
25377
|
+
properties: {
|
|
25378
|
+
source: {
|
|
25379
|
+
description: "A pattern that matches each incoming pathname (excluding querystring)",
|
|
25380
|
+
type: "string",
|
|
25381
|
+
maxLength: 4096
|
|
25382
|
+
},
|
|
25383
|
+
headers: {
|
|
25384
|
+
description: "An array of key/value pairs representing each response header.",
|
|
25385
|
+
type: "array",
|
|
25386
|
+
maxItems: 1024,
|
|
25387
|
+
items: {
|
|
25388
|
+
type: "object",
|
|
25389
|
+
additionalProperties: false,
|
|
25390
|
+
required: ["key", "value"],
|
|
25391
|
+
properties: {
|
|
25392
|
+
key: {
|
|
25393
|
+
type: "string",
|
|
25394
|
+
maxLength: 4096
|
|
25395
|
+
},
|
|
25396
|
+
value: {
|
|
25397
|
+
type: "string",
|
|
25398
|
+
maxLength: 32768
|
|
25399
|
+
}
|
|
25400
|
+
}
|
|
25401
|
+
}
|
|
25402
|
+
},
|
|
25403
|
+
has: hasSchema,
|
|
25404
|
+
missing: hasSchema
|
|
25405
|
+
}
|
|
25406
|
+
}
|
|
25407
|
+
};
|
|
25408
|
+
var cleanUrlsSchema = {
|
|
25409
|
+
description: "When set to `true`, all HTML files and Serverless Functions will have their extension removed. When visiting a path that ends with the extension, a 308 response will redirect the client to the extensionless path.",
|
|
25410
|
+
type: "boolean"
|
|
25411
|
+
};
|
|
25412
|
+
var trailingSlashSchema = {
|
|
25413
|
+
description: "When `false`, visiting a path that ends with a forward slash will respond with a `308` status code and redirect to the path without the trailing slash.",
|
|
25414
|
+
type: "boolean"
|
|
25415
|
+
};
|
|
25416
|
+
}
|
|
25417
|
+
});
|
|
25418
|
+
|
|
25419
|
+
// ../routing-utils/dist/types.js
|
|
25420
|
+
var require_types = __commonJS({
|
|
25421
|
+
"../routing-utils/dist/types.js"(exports, module2) {
|
|
25422
|
+
"use strict";
|
|
25423
|
+
var __defProp2 = Object.defineProperty;
|
|
25424
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
25425
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
25426
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
25427
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
25428
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25429
|
+
for (let key of __getOwnPropNames2(from))
|
|
25430
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
25431
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
25432
|
+
}
|
|
25433
|
+
return to;
|
|
25434
|
+
};
|
|
25435
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
25436
|
+
var types_exports = {};
|
|
25437
|
+
module2.exports = __toCommonJS2(types_exports);
|
|
25438
|
+
}
|
|
25439
|
+
});
|
|
25440
|
+
|
|
25441
|
+
// ../routing-utils/dist/index.js
|
|
25442
|
+
var require_dist4 = __commonJS({
|
|
25443
|
+
"../routing-utils/dist/index.js"(exports, module2) {
|
|
25444
|
+
"use strict";
|
|
25445
|
+
var __defProp2 = Object.defineProperty;
|
|
25446
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
25447
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
25448
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
25449
|
+
var __export2 = (target, all) => {
|
|
25450
|
+
for (var name in all)
|
|
25451
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
25452
|
+
};
|
|
25453
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
25454
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25455
|
+
for (let key of __getOwnPropNames2(from))
|
|
25456
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
25457
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
25458
|
+
}
|
|
25459
|
+
return to;
|
|
25460
|
+
};
|
|
25461
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps2(target, mod, "default"), secondTarget && __copyProps2(secondTarget, mod, "default"));
|
|
25462
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
25463
|
+
var src_exports2 = {};
|
|
25464
|
+
__export2(src_exports2, {
|
|
25465
|
+
appendRoutesToPhase: () => import_append.appendRoutesToPhase,
|
|
25466
|
+
compilePathToRegexpTemplate: () => import_superstatic2.compilePathToRegexpTemplate,
|
|
25467
|
+
convertRewrites: () => import_superstatic2.convertRewrites,
|
|
25468
|
+
getCleanUrls: () => import_superstatic2.getCleanUrls,
|
|
25469
|
+
getOwnershipGuard: () => import_service_route_ownership.getOwnershipGuard,
|
|
25470
|
+
getTransformedRoutes: () => getTransformedRoutes,
|
|
25471
|
+
isHandler: () => isHandler,
|
|
25472
|
+
isValidHandleValue: () => isValidHandleValue,
|
|
25473
|
+
mergeRoutes: () => import_merge.mergeRoutes,
|
|
25474
|
+
normalizeRoutePrefix: () => import_service_route_ownership.normalizeRoutePrefix,
|
|
25475
|
+
normalizeRoutes: () => normalizeRoutes,
|
|
25476
|
+
pathToRegexp: () => import_superstatic2.pathToRegexp,
|
|
25477
|
+
scopeRouteSourceToOwnership: () => import_service_route_ownership.scopeRouteSourceToOwnership,
|
|
25478
|
+
sourceToRegex: () => import_superstatic2.sourceToRegex
|
|
25479
|
+
});
|
|
25480
|
+
module2.exports = __toCommonJS2(src_exports2);
|
|
25481
|
+
var import_url = require("url");
|
|
25482
|
+
var import_superstatic = require_superstatic();
|
|
25483
|
+
var import_append = require_append();
|
|
25484
|
+
var import_merge = require_merge2();
|
|
25485
|
+
var import_service_route_ownership = require_service_route_ownership();
|
|
25486
|
+
__reExport(src_exports2, require_schemas(), module2.exports);
|
|
25487
|
+
var import_superstatic2 = require_superstatic();
|
|
25488
|
+
__reExport(src_exports2, require_types(), module2.exports);
|
|
25489
|
+
var VALID_HANDLE_VALUES = [
|
|
25490
|
+
"filesystem",
|
|
25491
|
+
"hit",
|
|
25492
|
+
"miss",
|
|
25493
|
+
"rewrite",
|
|
25494
|
+
"error",
|
|
25495
|
+
"resource"
|
|
25496
|
+
];
|
|
25497
|
+
var validHandleValues = new Set(VALID_HANDLE_VALUES);
|
|
25498
|
+
function isHandler(route) {
|
|
25499
|
+
return typeof route.handle !== "undefined";
|
|
25500
|
+
}
|
|
25501
|
+
function isValidHandleValue(handle) {
|
|
25502
|
+
return validHandleValues.has(handle);
|
|
25503
|
+
}
|
|
25504
|
+
function convertRouteAliases(route, index) {
|
|
25505
|
+
if (route.source !== void 0) {
|
|
25506
|
+
if (route.src !== void 0) {
|
|
25507
|
+
throw new Error(
|
|
25508
|
+
`Route at index ${index} cannot define both \`src\` and \`source\`. Please use only one.`
|
|
25509
|
+
);
|
|
25510
|
+
}
|
|
25511
|
+
route.src = route.source;
|
|
25512
|
+
delete route.source;
|
|
25513
|
+
}
|
|
25514
|
+
if (route.destination !== void 0) {
|
|
25515
|
+
if (route.dest !== void 0) {
|
|
25516
|
+
throw new Error(
|
|
25517
|
+
`Route at index ${index} cannot define both \`dest\` and \`destination\`. Please use only one.`
|
|
25518
|
+
);
|
|
25519
|
+
}
|
|
25520
|
+
if (typeof route.destination === "string") {
|
|
25521
|
+
route.dest = route.destination;
|
|
25522
|
+
delete route.destination;
|
|
25523
|
+
} else if (typeof route.destination.service === "string") {
|
|
25524
|
+
route.destination = { ...route.destination, type: "service" };
|
|
25525
|
+
}
|
|
25526
|
+
}
|
|
25527
|
+
if (route.statusCode !== void 0) {
|
|
25528
|
+
if (route.status !== void 0) {
|
|
25529
|
+
throw new Error(
|
|
25530
|
+
`Route at index ${index} cannot define both \`status\` and \`statusCode\`. Please use only one.`
|
|
25531
|
+
);
|
|
25532
|
+
}
|
|
25533
|
+
route.status = route.statusCode;
|
|
25534
|
+
delete route.statusCode;
|
|
25535
|
+
}
|
|
25536
|
+
}
|
|
25537
|
+
function normalizeRoutes(inputRoutes) {
|
|
25538
|
+
if (!inputRoutes || inputRoutes.length === 0) {
|
|
25539
|
+
return { routes: inputRoutes, error: null };
|
|
25540
|
+
}
|
|
25541
|
+
const routes = [];
|
|
25542
|
+
const handling = [];
|
|
25543
|
+
const errors = [];
|
|
25544
|
+
inputRoutes.forEach((r, i) => {
|
|
25545
|
+
const route = { ...r };
|
|
25546
|
+
routes.push(route);
|
|
25547
|
+
if (!isHandler(route)) {
|
|
25548
|
+
try {
|
|
25549
|
+
convertRouteAliases(route, i);
|
|
25550
|
+
} catch (err) {
|
|
25551
|
+
errors.push(err.message);
|
|
25552
|
+
}
|
|
25553
|
+
}
|
|
25554
|
+
const keys = Object.keys(route);
|
|
25555
|
+
if (isHandler(route)) {
|
|
25556
|
+
const { handle } = route;
|
|
25557
|
+
if (keys.length !== 1) {
|
|
25558
|
+
const unknownProp = keys.find((prop) => prop !== "handle");
|
|
25559
|
+
errors.push(
|
|
25560
|
+
`Route at index ${i} has unknown property \`${unknownProp}\`.`
|
|
25561
|
+
);
|
|
25562
|
+
} else if (!isValidHandleValue(handle)) {
|
|
25563
|
+
errors.push(
|
|
25564
|
+
`Route at index ${i} has unknown handle value \`handle: ${handle}\`.`
|
|
25565
|
+
);
|
|
25566
|
+
} else if (handling.includes(handle)) {
|
|
25567
|
+
errors.push(
|
|
25568
|
+
`Route at index ${i} is a duplicate. Please use one \`handle: ${handle}\` at most.`
|
|
25569
|
+
);
|
|
25570
|
+
} else {
|
|
25571
|
+
handling.push(handle);
|
|
25572
|
+
}
|
|
25573
|
+
} else if (route.src) {
|
|
25574
|
+
if (!route.src.startsWith("^")) {
|
|
25575
|
+
route.src = `^${route.src}`;
|
|
25576
|
+
}
|
|
25577
|
+
if (!route.src.endsWith("$")) {
|
|
25578
|
+
route.src = `${route.src}$`;
|
|
25579
|
+
}
|
|
25580
|
+
route.src = route.src.replace(/\\\//g, "/");
|
|
25581
|
+
const regError = checkRegexSyntax("Route", i, route.src);
|
|
25582
|
+
if (regError) {
|
|
25583
|
+
errors.push(regError);
|
|
25584
|
+
}
|
|
25585
|
+
if (route.destination && typeof route.destination === "object" && route.continue) {
|
|
25586
|
+
errors.push(
|
|
25587
|
+
`Route at index ${i} cannot define \`continue: true\` with a service \`destination\`. The service handoff is terminal.`
|
|
25588
|
+
);
|
|
25589
|
+
}
|
|
25590
|
+
const handleValue = handling[handling.length - 1];
|
|
25591
|
+
if (handleValue === "hit") {
|
|
25592
|
+
if (route.dest) {
|
|
25593
|
+
errors.push(
|
|
25594
|
+
`Route at index ${i} cannot define \`dest\`/\`destination\` after \`handle: hit\`.`
|
|
25595
|
+
);
|
|
25596
|
+
}
|
|
25597
|
+
if (route.status) {
|
|
25598
|
+
errors.push(
|
|
25599
|
+
`Route at index ${i} cannot define \`status\`/\`statusCode\` after \`handle: hit\`.`
|
|
25600
|
+
);
|
|
25601
|
+
}
|
|
25602
|
+
if (!route.continue) {
|
|
25603
|
+
errors.push(
|
|
25604
|
+
`Route at index ${i} must define \`continue: true\` after \`handle: hit\`.`
|
|
25605
|
+
);
|
|
25606
|
+
}
|
|
25607
|
+
} else if (handleValue === "miss") {
|
|
25608
|
+
if (route.dest && !route.check) {
|
|
25609
|
+
errors.push(
|
|
25610
|
+
`Route at index ${i} must define \`check: true\` after \`handle: miss\`.`
|
|
25611
|
+
);
|
|
25612
|
+
} else if (!route.dest && !route.continue) {
|
|
25613
|
+
errors.push(
|
|
25614
|
+
`Route at index ${i} must define \`continue: true\` after \`handle: miss\`.`
|
|
25615
|
+
);
|
|
25616
|
+
}
|
|
25617
|
+
}
|
|
25618
|
+
} else {
|
|
25619
|
+
errors.push(
|
|
25620
|
+
`Route at index ${i} must define either \`src\` or \`source\` property.`
|
|
25621
|
+
);
|
|
25622
|
+
}
|
|
25623
|
+
});
|
|
25624
|
+
const error = errors.length > 0 ? createError(
|
|
25625
|
+
"invalid_route",
|
|
25626
|
+
errors,
|
|
25627
|
+
"https://vercel.link/routes-json",
|
|
25628
|
+
"Learn More"
|
|
25629
|
+
) : null;
|
|
25630
|
+
return { routes, error };
|
|
25631
|
+
}
|
|
25632
|
+
function checkRegexSyntax(type, index, src) {
|
|
25633
|
+
try {
|
|
25634
|
+
new RegExp(src);
|
|
25635
|
+
} catch (_err) {
|
|
25636
|
+
const prop = type === "Route" ? "src`/`source" : "source";
|
|
25637
|
+
return `${type} at index ${index} has invalid \`${prop}\` regular expression "${src}".`;
|
|
25638
|
+
}
|
|
25639
|
+
return null;
|
|
25640
|
+
}
|
|
25641
|
+
function checkPatternSyntax(type, index, {
|
|
25642
|
+
source,
|
|
25643
|
+
destination,
|
|
25644
|
+
has,
|
|
25645
|
+
transforms
|
|
25646
|
+
}) {
|
|
25647
|
+
let sourceSegments = /* @__PURE__ */ new Set();
|
|
25648
|
+
const destinationSegments = /* @__PURE__ */ new Set();
|
|
25649
|
+
try {
|
|
25650
|
+
sourceSegments = new Set((0, import_superstatic.sourceToRegex)(source).segments);
|
|
25651
|
+
} catch (_err) {
|
|
25652
|
+
return {
|
|
25653
|
+
message: `${type} at index ${index} has invalid \`source\` pattern "${source}".`,
|
|
25654
|
+
link: "https://vercel.link/invalid-route-source-pattern"
|
|
25655
|
+
};
|
|
25656
|
+
}
|
|
25657
|
+
const destinationString = typeof destination === "string" ? destination : typeof destination?.path === "string" ? destination.path : void 0;
|
|
25658
|
+
if (destinationString !== void 0) {
|
|
25659
|
+
try {
|
|
25660
|
+
const { hostname, pathname, query } = (0, import_url.parse)(destinationString, true);
|
|
25661
|
+
(0, import_superstatic.sourceToRegex)(hostname || "").segments.forEach(
|
|
25662
|
+
(name) => destinationSegments.add(name)
|
|
25663
|
+
);
|
|
25664
|
+
(0, import_superstatic.sourceToRegex)(pathname || "").segments.forEach(
|
|
25665
|
+
(name) => destinationSegments.add(name)
|
|
25666
|
+
);
|
|
25667
|
+
for (const strOrArray of Object.values(query)) {
|
|
25668
|
+
const value = Array.isArray(strOrArray) ? strOrArray[0] : strOrArray;
|
|
25669
|
+
(0, import_superstatic.sourceToRegex)(value || "").segments.forEach(
|
|
25670
|
+
(name) => destinationSegments.add(name)
|
|
25671
|
+
);
|
|
25672
|
+
}
|
|
25673
|
+
} catch (_err) {
|
|
25674
|
+
}
|
|
25675
|
+
const hasSegments = (0, import_superstatic.collectHasSegments)(has);
|
|
25676
|
+
for (const segment of destinationSegments) {
|
|
25677
|
+
if (!sourceSegments.has(segment) && !hasSegments.includes(segment)) {
|
|
25678
|
+
return {
|
|
25679
|
+
message: `${type} at index ${index} has segment ":${segment}" in \`destination\` property but not in \`source\` or \`has\` property.`,
|
|
25680
|
+
link: "https://vercel.link/invalid-route-destination-segment"
|
|
25681
|
+
};
|
|
25682
|
+
}
|
|
25683
|
+
}
|
|
25684
|
+
}
|
|
25685
|
+
for (const transform of transforms || []) {
|
|
25686
|
+
if (transform.type !== "request.path") {
|
|
25687
|
+
continue;
|
|
25688
|
+
}
|
|
25689
|
+
try {
|
|
25690
|
+
(0, import_superstatic.compilePathToRegexpTemplate)(source, transform.args, has, transform.env);
|
|
25691
|
+
} catch (error) {
|
|
25692
|
+
return {
|
|
25693
|
+
message: `${type} at index ${index} has an invalid \`request.path\` transform: ${error instanceof Error ? error.message : String(error)}`,
|
|
25694
|
+
link: "https://vercel.link/invalid-route-destination-segment"
|
|
25695
|
+
};
|
|
25696
|
+
}
|
|
25697
|
+
}
|
|
25698
|
+
return null;
|
|
25699
|
+
}
|
|
25700
|
+
function checkRedirect(r, index) {
|
|
25701
|
+
if (typeof r.permanent !== "undefined" && typeof r.statusCode !== "undefined") {
|
|
25702
|
+
return `Redirect at index ${index} cannot define both \`permanent\` and \`statusCode\` properties.`;
|
|
25703
|
+
}
|
|
25704
|
+
return null;
|
|
25705
|
+
}
|
|
25706
|
+
function createError(code, allErrors, link, action) {
|
|
25707
|
+
const errors = Array.isArray(allErrors) ? allErrors : [allErrors];
|
|
25708
|
+
const message = errors[0];
|
|
25709
|
+
const error = {
|
|
25710
|
+
name: "RouteApiError",
|
|
25711
|
+
code,
|
|
25712
|
+
message,
|
|
25713
|
+
link,
|
|
25714
|
+
action,
|
|
25715
|
+
errors
|
|
25716
|
+
};
|
|
25717
|
+
return error;
|
|
25718
|
+
}
|
|
25719
|
+
function notEmpty(value) {
|
|
25720
|
+
return value !== null && value !== void 0;
|
|
25721
|
+
}
|
|
25722
|
+
function getTransformedRoutes(vercelConfig) {
|
|
25723
|
+
const { cleanUrls, rewrites, redirects, headers, trailingSlash } = vercelConfig;
|
|
25724
|
+
const { routes: userRoutes = null } = vercelConfig;
|
|
25725
|
+
let routes = null;
|
|
25726
|
+
if (typeof cleanUrls !== "undefined") {
|
|
25727
|
+
const normalized = normalizeRoutes(
|
|
25728
|
+
(0, import_superstatic.convertCleanUrls)(cleanUrls, trailingSlash)
|
|
25729
|
+
);
|
|
25730
|
+
if (normalized.error) {
|
|
25731
|
+
normalized.error.code = "invalid_clean_urls";
|
|
25732
|
+
return { routes, error: normalized.error };
|
|
25733
|
+
}
|
|
25734
|
+
routes = routes || [];
|
|
25735
|
+
routes.push(...normalized.routes || []);
|
|
25736
|
+
}
|
|
25737
|
+
if (typeof trailingSlash !== "undefined") {
|
|
25738
|
+
const normalized = normalizeRoutes((0, import_superstatic.convertTrailingSlash)(trailingSlash));
|
|
25739
|
+
if (normalized.error) {
|
|
25740
|
+
normalized.error.code = "invalid_trailing_slash";
|
|
25741
|
+
return { routes, error: normalized.error };
|
|
25742
|
+
}
|
|
25743
|
+
routes = routes || [];
|
|
25744
|
+
routes.push(...normalized.routes || []);
|
|
25745
|
+
}
|
|
25746
|
+
if (userRoutes) {
|
|
25747
|
+
const normalized = normalizeRoutes(userRoutes);
|
|
25748
|
+
if (normalized.error) {
|
|
25749
|
+
return { routes, error: normalized.error };
|
|
25750
|
+
}
|
|
25751
|
+
routes = routes || [];
|
|
25752
|
+
routes.push(...normalized.routes || []);
|
|
25753
|
+
}
|
|
25754
|
+
if (typeof redirects !== "undefined") {
|
|
25755
|
+
const code = "invalid_redirect";
|
|
25756
|
+
const regexErrorMessage = redirects.map((r, i) => checkRegexSyntax("Redirect", i, r.source)).find(notEmpty);
|
|
25757
|
+
if (regexErrorMessage) {
|
|
25758
|
+
return {
|
|
25759
|
+
routes,
|
|
25760
|
+
error: createError(
|
|
25761
|
+
"invalid_redirect",
|
|
25762
|
+
regexErrorMessage,
|
|
25763
|
+
"https://vercel.link/invalid-route-source-pattern",
|
|
25764
|
+
"Learn More"
|
|
25765
|
+
)
|
|
25766
|
+
};
|
|
25767
|
+
}
|
|
25768
|
+
const patternError = redirects.map((r, i) => checkPatternSyntax("Redirect", i, r)).find(notEmpty);
|
|
25769
|
+
if (patternError) {
|
|
25770
|
+
return {
|
|
25771
|
+
routes,
|
|
25772
|
+
error: createError(
|
|
25773
|
+
code,
|
|
25774
|
+
patternError.message,
|
|
25775
|
+
patternError.link,
|
|
25776
|
+
"Learn More"
|
|
25777
|
+
)
|
|
25778
|
+
};
|
|
25779
|
+
}
|
|
25780
|
+
const redirectErrorMessage = redirects.map(checkRedirect).find(notEmpty);
|
|
25781
|
+
if (redirectErrorMessage) {
|
|
25782
|
+
return {
|
|
25783
|
+
routes,
|
|
25784
|
+
error: createError(
|
|
25785
|
+
code,
|
|
25786
|
+
redirectErrorMessage,
|
|
25787
|
+
"https://vercel.link/redirects-json",
|
|
25788
|
+
"Learn More"
|
|
25789
|
+
)
|
|
25790
|
+
};
|
|
25791
|
+
}
|
|
25792
|
+
const normalized = normalizeRoutes((0, import_superstatic.convertRedirects)(redirects));
|
|
25793
|
+
if (normalized.error) {
|
|
25794
|
+
normalized.error.code = code;
|
|
25795
|
+
return { routes, error: normalized.error };
|
|
25796
|
+
}
|
|
25797
|
+
routes = routes || [];
|
|
25798
|
+
routes.push(...normalized.routes || []);
|
|
25799
|
+
}
|
|
25800
|
+
if (typeof headers !== "undefined") {
|
|
25801
|
+
const code = "invalid_header";
|
|
25802
|
+
const regexErrorMessage = headers.map((r, i) => checkRegexSyntax("Header", i, r.source)).find(notEmpty);
|
|
25803
|
+
if (regexErrorMessage) {
|
|
25804
|
+
return {
|
|
25805
|
+
routes,
|
|
25806
|
+
error: createError(
|
|
25807
|
+
code,
|
|
25808
|
+
regexErrorMessage,
|
|
25809
|
+
"https://vercel.link/invalid-route-source-pattern",
|
|
25810
|
+
"Learn More"
|
|
25811
|
+
)
|
|
25812
|
+
};
|
|
25813
|
+
}
|
|
25814
|
+
const patternError = headers.map((r, i) => checkPatternSyntax("Header", i, r)).find(notEmpty);
|
|
25815
|
+
if (patternError) {
|
|
25816
|
+
return {
|
|
25817
|
+
routes,
|
|
25818
|
+
error: createError(
|
|
25819
|
+
code,
|
|
25820
|
+
patternError.message,
|
|
25821
|
+
patternError.link,
|
|
25822
|
+
"Learn More"
|
|
25823
|
+
)
|
|
25824
|
+
};
|
|
25825
|
+
}
|
|
25826
|
+
const normalized = normalizeRoutes((0, import_superstatic.convertHeaders)(headers));
|
|
25827
|
+
if (normalized.error) {
|
|
25828
|
+
normalized.error.code = code;
|
|
25829
|
+
return { routes, error: normalized.error };
|
|
25830
|
+
}
|
|
25831
|
+
routes = routes || [];
|
|
25832
|
+
routes.push(...normalized.routes || []);
|
|
25833
|
+
}
|
|
25834
|
+
if (typeof rewrites !== "undefined") {
|
|
25835
|
+
const code = "invalid_rewrite";
|
|
25836
|
+
const regexErrorMessage = rewrites.map((r, i) => checkRegexSyntax("Rewrite", i, r.source)).find(notEmpty);
|
|
25837
|
+
if (regexErrorMessage) {
|
|
25838
|
+
return {
|
|
25839
|
+
routes,
|
|
25840
|
+
error: createError(
|
|
25841
|
+
code,
|
|
25842
|
+
regexErrorMessage,
|
|
25843
|
+
"https://vercel.link/invalid-route-source-pattern",
|
|
25844
|
+
"Learn More"
|
|
25845
|
+
)
|
|
25846
|
+
};
|
|
25847
|
+
}
|
|
25848
|
+
const patternError = rewrites.map((r, i) => checkPatternSyntax("Rewrite", i, r)).find(notEmpty);
|
|
25849
|
+
if (patternError) {
|
|
25850
|
+
return {
|
|
25851
|
+
routes,
|
|
25852
|
+
error: createError(
|
|
25853
|
+
code,
|
|
25854
|
+
patternError.message,
|
|
25855
|
+
patternError.link,
|
|
25856
|
+
"Learn More"
|
|
25857
|
+
)
|
|
25858
|
+
};
|
|
25859
|
+
}
|
|
25860
|
+
const normalized = normalizeRoutes((0, import_superstatic.convertRewrites)(rewrites));
|
|
25861
|
+
if (normalized.error) {
|
|
25862
|
+
normalized.error.code = code;
|
|
25863
|
+
return { routes, error: normalized.error };
|
|
25864
|
+
}
|
|
25865
|
+
routes = routes || [];
|
|
25866
|
+
routes.push({ handle: "filesystem" });
|
|
25867
|
+
routes.push(...normalized.routes || []);
|
|
25868
|
+
}
|
|
25869
|
+
return { routes, error: null };
|
|
25870
|
+
}
|
|
25871
|
+
}
|
|
25872
|
+
});
|
|
25873
|
+
|
|
23106
25874
|
// ../../node_modules/.pnpm/bytes@3.1.2/node_modules/bytes/index.js
|
|
23107
25875
|
var require_bytes = __commonJS({
|
|
23108
25876
|
"../../node_modules/.pnpm/bytes@3.1.2/node_modules/bytes/index.js"(exports, module2) {
|
|
@@ -31625,6 +34393,7 @@ __export(src_exports, {
|
|
|
31625
34393
|
getPrerenderChain: () => getPrerenderChain,
|
|
31626
34394
|
getPrettyError: () => getPrettyError,
|
|
31627
34395
|
getProvidedRuntime: () => getProvidedRuntime,
|
|
34396
|
+
getRegExpFromMatchers: () => getRegExpFromMatchers,
|
|
31628
34397
|
getReportedServiceType: () => getReportedServiceType,
|
|
31629
34398
|
getScriptName: () => getScriptName,
|
|
31630
34399
|
getServiceQueueTopicConfigs: () => getServiceQueueTopicConfigs,
|
|
@@ -31670,6 +34439,7 @@ __export(src_exports, {
|
|
|
31670
34439
|
readConfigFile: () => readConfigFile,
|
|
31671
34440
|
rename: () => rename,
|
|
31672
34441
|
resetCustomInstallCommandSet: () => resetCustomInstallCommandSet,
|
|
34442
|
+
resolveMiddlewareMatcher: () => resolveMiddlewareMatcher,
|
|
31673
34443
|
runBundleInstall: () => runBundleInstall,
|
|
31674
34444
|
runCustomInstallCommand: () => runCustomInstallCommand,
|
|
31675
34445
|
runNpmInstall: () => runNpmInstall,
|
|
@@ -36519,6 +39289,42 @@ ${entrypointsForMessage}`
|
|
|
36519
39289
|
};
|
|
36520
39290
|
}
|
|
36521
39291
|
|
|
39292
|
+
// src/middleware-matcher.ts
|
|
39293
|
+
var import_routing_utils = __toESM(require_dist4());
|
|
39294
|
+
function getRegExpFromMatchers(matcherOrMatchers) {
|
|
39295
|
+
if (!matcherOrMatchers) {
|
|
39296
|
+
return "^/.*$";
|
|
39297
|
+
}
|
|
39298
|
+
const matchers = Array.isArray(matcherOrMatchers) ? matcherOrMatchers : [matcherOrMatchers];
|
|
39299
|
+
const regExps = matchers.flatMap(getRegExpFromMatcher).join("|");
|
|
39300
|
+
return regExps;
|
|
39301
|
+
}
|
|
39302
|
+
function resolveMiddlewareMatcher(configuredMatcher, sourceMatcher, entrypoint) {
|
|
39303
|
+
if (configuredMatcher !== void 0 && sourceMatcher !== void 0) {
|
|
39304
|
+
throw new Error(
|
|
39305
|
+
`${entrypoint}: \`proxy.matcher\` in vercel.json conflicts with \`config.matcher\` exported from the proxy entrypoint. Configure the matcher in only one location.`
|
|
39306
|
+
);
|
|
39307
|
+
}
|
|
39308
|
+
return configuredMatcher ?? sourceMatcher;
|
|
39309
|
+
}
|
|
39310
|
+
function getRegExpFromMatcher(matcher, _index, allMatchers) {
|
|
39311
|
+
if (typeof matcher !== "string") {
|
|
39312
|
+
throw new Error(
|
|
39313
|
+
"Middleware's `config.matcher` must be a path matcher (string) or an array of path matchers (string[])"
|
|
39314
|
+
);
|
|
39315
|
+
}
|
|
39316
|
+
if (!matcher.startsWith("/")) {
|
|
39317
|
+
throw new Error(
|
|
39318
|
+
`Middleware's \`config.matcher\` values must start with "/". Received: ${matcher}`
|
|
39319
|
+
);
|
|
39320
|
+
}
|
|
39321
|
+
const regExps = [(0, import_routing_utils.pathToRegexp)("316", matcher).source];
|
|
39322
|
+
if (matcher === "/" && !allMatchers.includes("/index")) {
|
|
39323
|
+
regExps.push((0, import_routing_utils.pathToRegexp)("491", "/index").source);
|
|
39324
|
+
}
|
|
39325
|
+
return regExps;
|
|
39326
|
+
}
|
|
39327
|
+
|
|
36522
39328
|
// src/framework-helpers.ts
|
|
36523
39329
|
var BACKEND_FRAMEWORKS = [
|
|
36524
39330
|
"express",
|
|
@@ -37918,6 +40724,7 @@ function getExtendedPayload({
|
|
|
37918
40724
|
getPrerenderChain,
|
|
37919
40725
|
getPrettyError,
|
|
37920
40726
|
getProvidedRuntime,
|
|
40727
|
+
getRegExpFromMatchers,
|
|
37921
40728
|
getReportedServiceType,
|
|
37922
40729
|
getScriptName,
|
|
37923
40730
|
getServiceQueueTopicConfigs,
|
|
@@ -37963,6 +40770,7 @@ function getExtendedPayload({
|
|
|
37963
40770
|
readConfigFile,
|
|
37964
40771
|
rename,
|
|
37965
40772
|
resetCustomInstallCommandSet,
|
|
40773
|
+
resolveMiddlewareMatcher,
|
|
37966
40774
|
runBundleInstall,
|
|
37967
40775
|
runCustomInstallCommand,
|
|
37968
40776
|
runNpmInstall,
|