@vercel/routing-utils 4.0.0 → 5.0.1
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/superstatic.js +35 -4
- package/package.json +5 -4
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": "
|
|
3
|
+
"version": "5.0.1",
|
|
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": "6.3.0"
|
|
17
|
+
"path-to-regexp-updated": "npm:path-to-regexp@6.3.0",
|
|
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",
|