@vercel/routing-utils 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schemas.d.ts +4 -4
- package/dist/schemas.js +4 -4
- package/dist/superstatic.js +35 -4
- package/package.json +4 -3
package/dist/schemas.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare const hasSchema: {
|
|
|
48
48
|
*/
|
|
49
49
|
export declare const routesSchema: {
|
|
50
50
|
readonly type: "array";
|
|
51
|
-
readonly maxItems:
|
|
51
|
+
readonly maxItems: 2048;
|
|
52
52
|
readonly deprecated: true;
|
|
53
53
|
readonly description: "A list of routes objects used to rewrite paths to point towards other internal or external paths";
|
|
54
54
|
readonly example: readonly [{
|
|
@@ -269,7 +269,7 @@ export declare const routesSchema: {
|
|
|
269
269
|
};
|
|
270
270
|
export declare const rewritesSchema: {
|
|
271
271
|
readonly type: "array";
|
|
272
|
-
readonly maxItems:
|
|
272
|
+
readonly maxItems: 2048;
|
|
273
273
|
readonly description: "A list of rewrite definitions.";
|
|
274
274
|
readonly items: {
|
|
275
275
|
readonly type: "object";
|
|
@@ -388,7 +388,7 @@ export declare const rewritesSchema: {
|
|
|
388
388
|
export declare const redirectsSchema: {
|
|
389
389
|
readonly title: "Redirects";
|
|
390
390
|
readonly type: "array";
|
|
391
|
-
readonly maxItems:
|
|
391
|
+
readonly maxItems: 2048;
|
|
392
392
|
readonly description: "A list of redirect definitions.";
|
|
393
393
|
readonly items: {
|
|
394
394
|
readonly type: "object";
|
|
@@ -511,7 +511,7 @@ export declare const redirectsSchema: {
|
|
|
511
511
|
};
|
|
512
512
|
export declare const headersSchema: {
|
|
513
513
|
readonly type: "array";
|
|
514
|
-
readonly maxItems:
|
|
514
|
+
readonly maxItems: 2048;
|
|
515
515
|
readonly description: "A list of header definitions.";
|
|
516
516
|
readonly items: {
|
|
517
517
|
readonly type: "object";
|
package/dist/schemas.js
CHANGED
|
@@ -77,7 +77,7 @@ const hasSchema = {
|
|
|
77
77
|
};
|
|
78
78
|
const routesSchema = {
|
|
79
79
|
type: "array",
|
|
80
|
-
maxItems:
|
|
80
|
+
maxItems: 2048,
|
|
81
81
|
deprecated: true,
|
|
82
82
|
description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
|
|
83
83
|
example: [{ dest: "https://docs.example.com", src: "/docs" }],
|
|
@@ -206,7 +206,7 @@ const routesSchema = {
|
|
|
206
206
|
};
|
|
207
207
|
const rewritesSchema = {
|
|
208
208
|
type: "array",
|
|
209
|
-
maxItems:
|
|
209
|
+
maxItems: 2048,
|
|
210
210
|
description: "A list of rewrite definitions.",
|
|
211
211
|
items: {
|
|
212
212
|
type: "object",
|
|
@@ -237,7 +237,7 @@ const rewritesSchema = {
|
|
|
237
237
|
const redirectsSchema = {
|
|
238
238
|
title: "Redirects",
|
|
239
239
|
type: "array",
|
|
240
|
-
maxItems:
|
|
240
|
+
maxItems: 2048,
|
|
241
241
|
description: "A list of redirect definitions.",
|
|
242
242
|
items: {
|
|
243
243
|
type: "object",
|
|
@@ -272,7 +272,7 @@ const redirectsSchema = {
|
|
|
272
272
|
};
|
|
273
273
|
const headersSchema = {
|
|
274
274
|
type: "array",
|
|
275
|
-
maxItems:
|
|
275
|
+
maxItems: 2048,
|
|
276
276
|
description: "A list of header definitions.",
|
|
277
277
|
items: {
|
|
278
278
|
type: "object",
|
package/dist/superstatic.js
CHANGED
|
@@ -30,6 +30,37 @@ __export(superstatic_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(superstatic_exports);
|
|
31
31
|
var import_url = require("url");
|
|
32
32
|
var import_path_to_regexp = require("path-to-regexp");
|
|
33
|
+
var import_path_to_regexp_updated = require("path-to-regexp-updated");
|
|
34
|
+
function pathToRegexp(callerId, path, keys, options) {
|
|
35
|
+
const currentRegExp = (0, import_path_to_regexp.pathToRegexp)(path, keys, options);
|
|
36
|
+
try {
|
|
37
|
+
const currentKeys = keys;
|
|
38
|
+
const newKeys = [];
|
|
39
|
+
const newRegExp = (0, import_path_to_regexp_updated.pathToRegexp)(path, newKeys, options);
|
|
40
|
+
const isDiffRegExp = currentRegExp.toString() !== newRegExp.toString();
|
|
41
|
+
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffRegExp) {
|
|
42
|
+
const message = JSON.stringify({
|
|
43
|
+
path,
|
|
44
|
+
currentRegExp: currentRegExp.toString(),
|
|
45
|
+
newRegExp: newRegExp.toString()
|
|
46
|
+
});
|
|
47
|
+
console.error(`[vc] PATH TO REGEXP PATH DIFF @ #${callerId}: ${message}`);
|
|
48
|
+
}
|
|
49
|
+
const isDiffKeys = keys?.toString() !== newKeys?.toString();
|
|
50
|
+
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffKeys) {
|
|
51
|
+
const message = JSON.stringify({
|
|
52
|
+
isDiffKeys,
|
|
53
|
+
currentKeys,
|
|
54
|
+
newKeys
|
|
55
|
+
});
|
|
56
|
+
console.error(`[vc] PATH TO REGEXP KEYS DIFF @ #${callerId}: ${message}`);
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
const error = err;
|
|
60
|
+
console.error(`[vc] PATH TO REGEXP ERROR @ #${callerId}: ${error.message}`);
|
|
61
|
+
}
|
|
62
|
+
return currentRegExp;
|
|
63
|
+
}
|
|
33
64
|
const UN_NAMED_SEGMENT = "__UN_NAMED_SEGMENT__";
|
|
34
65
|
function getCleanUrls(filePaths) {
|
|
35
66
|
const htmlFiles = filePaths.map(toRoute).filter((f) => f.endsWith(".html")).map((f) => ({
|
|
@@ -185,7 +216,7 @@ function convertTrailingSlash(enable, status = 308) {
|
|
|
185
216
|
}
|
|
186
217
|
function sourceToRegex(source) {
|
|
187
218
|
const keys = [];
|
|
188
|
-
const r = (
|
|
219
|
+
const r = pathToRegexp("632", source, keys, {
|
|
189
220
|
strict: true,
|
|
190
221
|
sensitive: true,
|
|
191
222
|
delimiter: "/"
|
|
@@ -258,9 +289,9 @@ function replaceSegments(segments, hasItemSegments, destination, isRedirect, int
|
|
|
258
289
|
const hashKeys = [];
|
|
259
290
|
const hostnameKeys = [];
|
|
260
291
|
try {
|
|
261
|
-
(
|
|
262
|
-
(
|
|
263
|
-
(
|
|
292
|
+
pathToRegexp("528", pathname, pathnameKeys);
|
|
293
|
+
pathToRegexp("834", hash || "", hashKeys);
|
|
294
|
+
pathToRegexp("712", hostname || "", hostnameKeys);
|
|
264
295
|
} catch (_) {
|
|
265
296
|
}
|
|
266
297
|
destParams = new Set(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/routing-utils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Vercel routing utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,17 +14,18 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"path-to-regexp-updated": "npm:path-to-regexp@6.3.0",
|
|
17
18
|
"path-to-regexp": "6.1.0"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/jest": "27.4.1",
|
|
21
22
|
"@types/node": "14.18.33",
|
|
22
|
-
"ajv": "^6.
|
|
23
|
+
"ajv": "^6.12.3",
|
|
23
24
|
"jest-junit": "16.0.0",
|
|
24
25
|
"typescript": "4.9.5"
|
|
25
26
|
},
|
|
26
27
|
"optionalDependencies": {
|
|
27
|
-
"ajv": "^6.
|
|
28
|
+
"ajv": "^6.12.3"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "node ../../utils/build.mjs",
|