@suveren/gateway 0.7.4 → 0.7.6
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/control-plane/index.mjs +248 -58
- package/dist/mcp-server/http.mjs +408 -65
- package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
- package/dist/ui/assets/index-CsrM6RQr.js +110 -0
- package/dist/ui/index.html +2 -2
- package/node_modules/@hap/core/dist/index.d.mts +258 -9
- package/node_modules/@hap/core/dist/index.d.ts +258 -9
- package/node_modules/@hap/core/dist/index.js +227 -5
- package/node_modules/@hap/core/dist/index.mjs +213 -4
- package/node_modules/@hap/core/package.json +3 -2
- package/node_modules/@hap/core/src/did-key.ts +126 -0
- package/node_modules/@hap/core/src/identity.ts +21 -5
- package/node_modules/@hap/core/src/index.ts +3 -0
- package/node_modules/@hap/core/src/mandate.ts +207 -0
- package/node_modules/@hap/core/src/receipt.ts +74 -0
- package/node_modules/@hap/core/src/types.ts +81 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.buffer.d.ts +5 -5
- package/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@types/node/http.d.ts +16 -0
- package/node_modules/@types/node/http2.d.ts +10 -2
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/process.d.ts +52 -0
- package/node_modules/@types/node/quic.d.ts +210 -28
- package/node_modules/@types/node/sqlite.d.ts +6 -2
- package/node_modules/@types/node/test.d.ts +36 -0
- package/node_modules/fast-uri/index.js +201 -48
- package/node_modules/fast-uri/lib/schemes.js +9 -4
- package/node_modules/fast-uri/lib/utils.js +388 -91
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
- package/node_modules/fast-uri/test/equal.test.js +31 -3
- package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
- package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
- package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
- package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
- package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
- package/node_modules/fast-uri/test/parse.test.js +7 -3
- package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
- package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
- package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
- package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
- package/node_modules/fast-uri/test/security.test.js +75 -3
- package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
- package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
- package/node_modules/hono/dist/cjs/client/client.js +25 -11
- package/node_modules/hono/dist/cjs/client/utils.js +4 -1
- package/node_modules/hono/dist/cjs/context.js +4 -0
- package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
- package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
- package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
- package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/cjs/request.js +8 -4
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/cjs/router/utils.js +27 -0
- package/node_modules/hono/dist/cjs/utils/body.js +15 -3
- package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
- package/node_modules/hono/dist/cjs/utils/url.js +9 -1
- package/node_modules/hono/dist/client/client.js +25 -11
- package/node_modules/hono/dist/client/utils.js +4 -1
- package/node_modules/hono/dist/context.js +4 -0
- package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
- package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
- package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
- package/node_modules/hono/dist/jsx/dom/render.js +2 -0
- package/node_modules/hono/dist/middleware/cache/index.js +1 -1
- package/node_modules/hono/dist/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
- package/node_modules/hono/dist/middleware/etag/index.js +3 -3
- package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/request.js +8 -4
- package/node_modules/hono/dist/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
- package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
- package/node_modules/hono/dist/router/trie-router/node.js +46 -69
- package/node_modules/hono/dist/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/router/utils.js +5 -0
- package/node_modules/hono/dist/types/context.d.ts +4 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
- package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
- package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
- package/node_modules/hono/dist/utils/body.js +15 -3
- package/node_modules/hono/dist/utils/cookie.js +1 -1
- package/node_modules/hono/dist/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/utils/stream.js +7 -1
- package/node_modules/hono/dist/utils/url.js +9 -1
- package/node_modules/hono/package.json +1 -1
- package/node_modules/is-plain-object/README.md +39 -95
- package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
- package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
- package/node_modules/is-plain-object/package.json +8 -34
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +12 -17
- package/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
- package/node_modules/jose/dist/types/types.d.ts +4 -2
- package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +32 -21
- package/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
- package/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
- package/node_modules/jose/dist/webapi/jwks/local.js +45 -53
- package/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
- package/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
- package/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
- package/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
- package/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
- package/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
- package/node_modules/jose/dist/webapi/key/import.js +16 -12
- package/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
- package/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
- package/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +45 -13
- package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
- package/node_modules/jose/dist/webapi/lib/key.js +24 -9
- package/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
- package/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
- package/node_modules/jose/dist/webapi/lib/options.js +26 -0
- package/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
- package/node_modules/jose/package.json +1 -1
- package/package.json +2 -2
- package/dist/ui/assets/index-0Q2eNytX.js +0 -110
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
|
@@ -26,6 +26,10 @@ var createProxy = (callback, path) => {
|
|
|
26
26
|
});
|
|
27
27
|
return proxy;
|
|
28
28
|
};
|
|
29
|
+
var appendQueryParams = (url, searchParams) => {
|
|
30
|
+
const queryString = searchParams.toString();
|
|
31
|
+
return queryString ? `${url}?${queryString}` : url;
|
|
32
|
+
};
|
|
29
33
|
var ClientRequestImpl = class {
|
|
30
34
|
url;
|
|
31
35
|
method;
|
|
@@ -52,6 +56,9 @@ var ClientRequestImpl = class {
|
|
|
52
56
|
}
|
|
53
57
|
if (Array.isArray(v)) {
|
|
54
58
|
for (const v2 of v) {
|
|
59
|
+
if (v2 === void 0) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
55
62
|
form.append(k, v2);
|
|
56
63
|
}
|
|
57
64
|
} else {
|
|
@@ -76,19 +83,29 @@ var ClientRequestImpl = class {
|
|
|
76
83
|
if (args?.cookie) {
|
|
77
84
|
const cookies = [];
|
|
78
85
|
for (const [key, value] of Object.entries(args.cookie)) {
|
|
86
|
+
if (value === void 0) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
79
89
|
cookies.push(serialize(key, value));
|
|
80
90
|
}
|
|
81
|
-
|
|
91
|
+
if (cookies.length > 0) {
|
|
92
|
+
headerValues["Cookie"] = cookies.join("; ");
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
if (this.cType) {
|
|
84
96
|
headerValues["Content-Type"] = this.cType;
|
|
85
97
|
}
|
|
86
|
-
const headers = new Headers(
|
|
98
|
+
const headers = new Headers();
|
|
99
|
+
for (const [key, value] of Object.entries(headerValues)) {
|
|
100
|
+
if (value !== void 0) {
|
|
101
|
+
headers.set(key, value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
87
104
|
let url = this.url;
|
|
88
105
|
url = removeIndexString(url);
|
|
89
106
|
url = replaceUrlParam(url, this.pathParams);
|
|
90
107
|
if (this.queryParams) {
|
|
91
|
-
url = url
|
|
108
|
+
url = appendQueryParams(url, this.queryParams);
|
|
92
109
|
}
|
|
93
110
|
methodUpperCase = this.method.toUpperCase();
|
|
94
111
|
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
@@ -132,7 +149,7 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
132
149
|
result = replaceUrlParam(url, opts.args[0].param);
|
|
133
150
|
}
|
|
134
151
|
if (opts.args[0].query) {
|
|
135
|
-
result = result
|
|
152
|
+
result = appendQueryParams(result, buildSearchParamsOption(opts.args[0].query));
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
155
|
result = removeIndexString(result);
|
|
@@ -143,18 +160,15 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
143
160
|
}
|
|
144
161
|
if (method === "ws") {
|
|
145
162
|
const webSocketUrl = replaceUrlProtocol(
|
|
146
|
-
opts.args[0]
|
|
163
|
+
opts.args[0]?.param ? replaceUrlParam(url, opts.args[0].param) : url,
|
|
147
164
|
"ws"
|
|
148
165
|
);
|
|
149
166
|
const targetUrl = new URL(webSocketUrl);
|
|
150
167
|
const queryParams = opts.args[0]?.query;
|
|
151
168
|
if (queryParams) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} else {
|
|
156
|
-
targetUrl.searchParams.set(key, value);
|
|
157
|
-
}
|
|
169
|
+
const searchParams = buildSearchParamsOption(queryParams);
|
|
170
|
+
searchParams.forEach((value, key) => {
|
|
171
|
+
targetUrl.searchParams.append(key, value);
|
|
158
172
|
});
|
|
159
173
|
}
|
|
160
174
|
const establishWebSocket = (...args) => {
|
|
@@ -9,7 +9,7 @@ var mergePath = (base, path) => {
|
|
|
9
9
|
var replaceUrlParam = (urlString, params) => {
|
|
10
10
|
for (const [k, v] of Object.entries(params)) {
|
|
11
11
|
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
12
|
-
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
12
|
+
urlString = urlString.replace(reg, () => v ? `/${v}` : "");
|
|
13
13
|
}
|
|
14
14
|
return urlString;
|
|
15
15
|
};
|
|
@@ -21,6 +21,9 @@ var buildSearchParams = (query) => {
|
|
|
21
21
|
}
|
|
22
22
|
if (Array.isArray(v)) {
|
|
23
23
|
for (const v2 of v) {
|
|
24
|
+
if (v2 === void 0) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
24
27
|
searchParams.append(k, v2);
|
|
25
28
|
}
|
|
26
29
|
} else {
|
|
@@ -202,6 +202,10 @@ var Context = class {
|
|
|
202
202
|
* c.header('X-Message', 'Hello!')
|
|
203
203
|
* c.header('Content-Type', 'text/plain')
|
|
204
204
|
*
|
|
205
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
206
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
207
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
208
|
+
*
|
|
205
209
|
* return c.body('Thank you for coming')
|
|
206
210
|
* })
|
|
207
211
|
* ```
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
// src/helper/accepts/accepts.ts
|
|
2
2
|
import { parseAccept } from "../../utils/accept.js";
|
|
3
|
+
var matchType = (acceptType, supportedType) => {
|
|
4
|
+
if (acceptType === supportedType) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (acceptType === "*/*" || acceptType === "*") {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (acceptType.endsWith("/*")) {
|
|
11
|
+
const [acceptMain] = acceptType.split("/");
|
|
12
|
+
const [supportedMain] = supportedType.split("/");
|
|
13
|
+
return acceptMain === supportedMain;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
var getSpecificity = (type) => {
|
|
18
|
+
if (type === "*/*" || type === "*") {
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
if (type.endsWith("/*")) {
|
|
22
|
+
return 2;
|
|
23
|
+
}
|
|
24
|
+
return 3;
|
|
25
|
+
};
|
|
3
26
|
var defaultMatch = (accepts2, config) => {
|
|
4
27
|
const { supports, default: defaultSupport } = config;
|
|
5
|
-
const
|
|
6
|
-
|
|
28
|
+
const sortedAccepts = accepts2.slice().sort((a, b) => {
|
|
29
|
+
if (b.q !== a.q) {
|
|
30
|
+
return b.q - a.q;
|
|
31
|
+
}
|
|
32
|
+
return getSpecificity(b.type) - getSpecificity(a.type);
|
|
33
|
+
});
|
|
34
|
+
for (const accept of sortedAccepts) {
|
|
35
|
+
const matched = supports.find((supported) => matchType(accept.type, supported));
|
|
36
|
+
if (matched) {
|
|
37
|
+
return matched;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return defaultSupport;
|
|
7
41
|
};
|
|
8
42
|
var accepts = (c, options) => {
|
|
9
43
|
const acceptHeader = c.req.header(options.header);
|
|
@@ -184,7 +184,7 @@ var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
|
184
184
|
const { routePath, content, mimeType } = awaitedData;
|
|
185
185
|
const filePath = generateFilePath(routePath, outDir, mimeType, extensionMap);
|
|
186
186
|
const dirPath = dirname(filePath);
|
|
187
|
-
if (!createdDirs.has(dirPath)) {
|
|
187
|
+
if (dirPath !== "" && !createdDirs.has(dirPath)) {
|
|
188
188
|
await fsModule.mkdir(dirPath, { recursive: true });
|
|
189
189
|
createdDirs.add(dirPath);
|
|
190
190
|
}
|
|
@@ -8,8 +8,14 @@ var dirname = (path) => {
|
|
|
8
8
|
var normalizePath = (path) => {
|
|
9
9
|
return path.replace(/(\\)/g, "/").replace(/\/$/g, "");
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
11
|
+
var getUncRoot = (path) => {
|
|
12
|
+
const uncRoot = path.replace(/\\/g, "/").match(/^\/\/([^/]+)\/([^/]+)/);
|
|
13
|
+
if (uncRoot) {
|
|
14
|
+
return `${uncRoot[1].toLowerCase()}/${uncRoot[2].toLowerCase()}`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var handleParent = (resultPaths) => {
|
|
18
|
+
if (resultPaths.length === 0 || resultPaths[resultPaths.length - 1] === "..") {
|
|
13
19
|
resultPaths.push("..");
|
|
14
20
|
} else {
|
|
15
21
|
resultPaths.pop();
|
|
@@ -22,22 +28,20 @@ var handleNonDot = (path, resultPaths) => {
|
|
|
22
28
|
}
|
|
23
29
|
};
|
|
24
30
|
var handleSegments = (paths, resultPaths) => {
|
|
25
|
-
let beforeParentFlag = false;
|
|
26
31
|
for (const path of paths) {
|
|
27
32
|
if (path === "..") {
|
|
28
|
-
handleParent(resultPaths
|
|
29
|
-
beforeParentFlag = true;
|
|
33
|
+
handleParent(resultPaths);
|
|
30
34
|
} else {
|
|
31
35
|
handleNonDot(path, resultPaths);
|
|
32
|
-
beforeParentFlag = false;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
var joinPaths = (...paths) => {
|
|
40
|
+
const hasUncPrefix = getUncRoot(paths[0]) !== void 0;
|
|
37
41
|
paths = paths.map(normalizePath);
|
|
38
42
|
const resultPaths = [];
|
|
39
43
|
handleSegments(paths.join("/").split("/"), resultPaths);
|
|
40
|
-
return (paths[0][0] === "/" ? "/" : "") + resultPaths.join("/");
|
|
44
|
+
return (hasUncPrefix ? "//" : paths[0][0] === "/" ? "/" : "") + resultPaths.join("/");
|
|
41
45
|
};
|
|
42
46
|
var filterStaticGenerateRoutes = (hono) => {
|
|
43
47
|
return hono.routes.reduce((acc, { method, handler, path }) => {
|
|
@@ -51,10 +55,26 @@ var filterStaticGenerateRoutes = (hono) => {
|
|
|
51
55
|
var isDynamicRoute = (path) => {
|
|
52
56
|
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
53
57
|
};
|
|
58
|
+
var toSegments = (path) => path === "" ? [] : path.split("/");
|
|
59
|
+
var getPathRoot = (path) => {
|
|
60
|
+
const normalizedPath = path.replace(/\\/g, "/");
|
|
61
|
+
const uncRoot = getUncRoot(normalizedPath);
|
|
62
|
+
if (uncRoot) {
|
|
63
|
+
return `unc:${uncRoot}`;
|
|
64
|
+
}
|
|
65
|
+
const driveRoot = normalizedPath.match(/^([A-Za-z]):/);
|
|
66
|
+
if (driveRoot) {
|
|
67
|
+
const kind = normalizedPath[2] === "/" ? "drive-absolute" : "drive-relative";
|
|
68
|
+
return `${kind}:${driveRoot[1].toLowerCase()}`;
|
|
69
|
+
}
|
|
70
|
+
return normalizedPath.startsWith("/") ? "absolute" : "relative";
|
|
71
|
+
};
|
|
54
72
|
var ensureWithinOutDir = (outDir, filePath) => {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
73
|
+
const outDirSegments = toSegments(joinPaths(outDir));
|
|
74
|
+
const filePathSegments = toSegments(joinPaths(filePath));
|
|
75
|
+
const hasMismatchedPathRoot = getPathRoot(outDir) !== getPathRoot(filePath);
|
|
76
|
+
const climbsAboveOutDir = filePathSegments[outDirSegments.length] === "..";
|
|
77
|
+
if (hasMismatchedPathRoot || filePathSegments.length <= outDirSegments.length || !outDirSegments.every((segment, i) => segment === filePathSegments[i]) || climbsAboveOutDir) {
|
|
58
78
|
throw new Error(`Path traversal detected: "${filePath}" is outside the output directory`);
|
|
59
79
|
}
|
|
60
80
|
};
|
|
@@ -78,6 +78,7 @@ var applyProps = (container, attributes, oldAttributes) => {
|
|
|
78
78
|
} else if (key === "dangerouslySetInnerHTML" && value) {
|
|
79
79
|
container.innerHTML = value.__html;
|
|
80
80
|
} else if (key === "ref") {
|
|
81
|
+
refCleanupMap.get(container)?.();
|
|
81
82
|
let cleanup;
|
|
82
83
|
if (typeof value === "function") {
|
|
83
84
|
cleanup = value(container) || (() => value(null));
|
|
@@ -142,6 +143,7 @@ var applyProps = (container, attributes, oldAttributes) => {
|
|
|
142
143
|
container.removeEventListener(eventSpec[0], value, eventSpec[1]);
|
|
143
144
|
} else if (key === "ref") {
|
|
144
145
|
refCleanupMap.get(container)?.();
|
|
146
|
+
refCleanupMap.delete(container);
|
|
145
147
|
} else {
|
|
146
148
|
try {
|
|
147
149
|
container.removeAttribute(toAttributeName(container, key));
|
|
@@ -23,7 +23,7 @@ var parseVaryDirectives = (vary) => {
|
|
|
23
23
|
};
|
|
24
24
|
var createCacheKey = (key, requestUrl, request, varyHeaders) => {
|
|
25
25
|
const url = new URL(cacheKeyPath, requestUrl);
|
|
26
|
-
url.searchParams.append(cacheKeyParameter, key
|
|
26
|
+
url.searchParams.append(cacheKeyParameter, key);
|
|
27
27
|
url.searchParams.append(cacheMethodKeyParameter, request.method);
|
|
28
28
|
if (request.method === "QUERY") {
|
|
29
29
|
url.searchParams.append(queryDigestKeyParameter, request.digest);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { HTTPException } from "../../http-exception.js";
|
|
3
3
|
var secFetchSiteValues = ["same-origin", "same-site", "none", "cross-site"];
|
|
4
4
|
var isSecFetchSite = (value) => secFetchSiteValues.includes(value);
|
|
5
|
-
var isSafeMethodRe = /^(GET|HEAD)$/;
|
|
5
|
+
var isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
|
|
6
6
|
var isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
7
7
|
var csrf = (options) => {
|
|
8
8
|
const originHandler = ((optsOrigin) => {
|
|
@@ -38,7 +38,7 @@ var generateDigest = async (stream, generator) => {
|
|
|
38
38
|
const requiredLength = chunkLength + remaining;
|
|
39
39
|
if (requiredLength < CHUNK_SIZE) {
|
|
40
40
|
if (!chunk) {
|
|
41
|
-
chunk = value.
|
|
41
|
+
chunk = value.slice(offset);
|
|
42
42
|
} else {
|
|
43
43
|
if (chunk.byteLength < requiredLength) {
|
|
44
44
|
const nextChunk = new Uint8Array(
|
|
@@ -10,7 +10,7 @@ var RETAINED_304_HEADERS = [
|
|
|
10
10
|
];
|
|
11
11
|
var stripWeak = (tag) => tag.replace(/^W\//, "");
|
|
12
12
|
function etagMatches(etag2, ifNoneMatch) {
|
|
13
|
-
return ifNoneMatch != null && ifNoneMatch.split(
|
|
13
|
+
return ifNoneMatch != null && ifNoneMatch.split(",").some((t) => stripWeak(t.trim()) === stripWeak(etag2));
|
|
14
14
|
}
|
|
15
15
|
function initializeGenerator(generator) {
|
|
16
16
|
if (!generator) {
|
|
@@ -60,11 +60,11 @@ var etag = (options) => {
|
|
|
60
60
|
ETag: etag3
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
c.res.headers.
|
|
63
|
+
for (const key of Array.from(c.res.headers.keys())) {
|
|
64
64
|
if (retainedHeaders.indexOf(key.toLowerCase()) === -1) {
|
|
65
65
|
c.res.headers.delete(key);
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
} else {
|
|
69
69
|
c.res.headers.set("ETag", etag3);
|
|
70
70
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/middleware/pretty-json/index.ts
|
|
2
|
+
var jsonContentTypeRegex = /^application\/(?:[a-z0-9._-]+\+)?json(?=$|[;\s])/i;
|
|
2
3
|
var prettyJSON = (options) => {
|
|
3
4
|
const targetQuery = options?.query ?? "pretty";
|
|
4
5
|
return async function prettyJSON2(c, next) {
|
|
5
6
|
const pretty = options?.force || c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
6
7
|
await next();
|
|
7
|
-
|
|
8
|
+
const contentType = c.res.headers.get("Content-Type");
|
|
9
|
+
if (pretty && contentType && jsonContentTypeRegex.test(contentType)) {
|
|
8
10
|
const obj = await c.res.json();
|
|
9
11
|
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
10
12
|
}
|
|
@@ -46,13 +46,13 @@ var HonoRequest = class {
|
|
|
46
46
|
return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
|
|
47
47
|
}
|
|
48
48
|
#getDecodedParam(key) {
|
|
49
|
-
const paramKey = this.#matchResult[0][this.routeIndex][1][key];
|
|
49
|
+
const paramKey = this.#matchResult[0][this.routeIndex]?.[1][key];
|
|
50
50
|
const param = this.#getParamValue(paramKey);
|
|
51
51
|
return param && tryDecodeURIComponent(param);
|
|
52
52
|
}
|
|
53
53
|
#getAllDecodedParams() {
|
|
54
54
|
const decoded = {};
|
|
55
|
-
const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
|
|
55
|
+
const keys = Object.keys(this.#matchResult[0][this.routeIndex]?.[1] ?? {});
|
|
56
56
|
for (const key of keys) {
|
|
57
57
|
const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
|
|
58
58
|
if (value !== void 0) {
|
|
@@ -292,10 +292,14 @@ var cloneRawRequest = async (req) => {
|
|
|
292
292
|
message: "Cannot clone request: body was already consumed and not cached. Please use HonoRequest methods (e.g., req.json(), req.text()) instead of consuming req.raw directly."
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
let body = await req[cacheKey]();
|
|
296
296
|
const headers = req.header();
|
|
297
|
-
if (
|
|
297
|
+
if (cacheKey === "json") {
|
|
298
|
+
body = JSON.stringify(body);
|
|
299
|
+
delete headers["content-length"];
|
|
300
|
+
} else if (body instanceof FormData) {
|
|
298
301
|
delete headers["content-type"];
|
|
302
|
+
delete headers["content-length"];
|
|
299
303
|
}
|
|
300
304
|
const requestInit = {
|
|
301
305
|
body,
|
|
@@ -29,7 +29,8 @@ var LinearRouter = class {
|
|
|
29
29
|
}
|
|
30
30
|
} else if (hasStar && !hasLabel) {
|
|
31
31
|
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
|
|
32
|
-
const
|
|
32
|
+
const endsWithSlashStar = routePath.endsWith("/*");
|
|
33
|
+
const parts = (endsWithStar ? routePath.slice(0, endsWithSlashStar ? -2 : -1) : routePath).split(splitByStarRe);
|
|
33
34
|
const lastIndex = parts.length - 1;
|
|
34
35
|
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
|
|
35
36
|
const part = parts[j];
|
|
@@ -39,7 +40,11 @@ var LinearRouter = class {
|
|
|
39
40
|
}
|
|
40
41
|
pos += part.length;
|
|
41
42
|
if (j === lastIndex) {
|
|
42
|
-
if (
|
|
43
|
+
if (endsWithSlashStar) {
|
|
44
|
+
if (pos !== path.length && path.charCodeAt(pos) !== 47) {
|
|
45
|
+
continue ROUTES_LOOP;
|
|
46
|
+
}
|
|
47
|
+
} else if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
|
|
43
48
|
continue ROUTES_LOOP;
|
|
44
49
|
}
|
|
45
50
|
} else {
|
|
@@ -5,10 +5,8 @@ var PatternRouter = class {
|
|
|
5
5
|
name = "PatternRouter";
|
|
6
6
|
#routes = [];
|
|
7
7
|
add(method, path, handler) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
path = path.slice(0, -2);
|
|
11
|
-
}
|
|
8
|
+
const suffix = path.endsWith("/*") ? "(?:$|/)" : path.endsWith("*") ? "" : "/?$";
|
|
9
|
+
path = path.replace(/\*$/, "");
|
|
12
10
|
if (path.at(-1) === "?") {
|
|
13
11
|
path = path.slice(0, -1);
|
|
14
12
|
this.add(method, path.replace(/\/[^/]+$/, ""), handler);
|
|
@@ -20,11 +18,7 @@ var PatternRouter = class {
|
|
|
20
18
|
}
|
|
21
19
|
);
|
|
22
20
|
try {
|
|
23
|
-
this.#routes.push([
|
|
24
|
-
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
25
|
-
method,
|
|
26
|
-
handler
|
|
27
|
-
]);
|
|
21
|
+
this.#routes.push([new RegExp(`^${parts.join("")}${suffix}`), method, handler]);
|
|
28
22
|
} catch {
|
|
29
23
|
throw new UnsupportedPathError();
|
|
30
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/router/reg-exp-router/node.ts
|
|
2
|
+
import { createNullObject } from "../utils.js";
|
|
2
3
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
3
4
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
4
5
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -27,7 +28,7 @@ var Node = class _Node {
|
|
|
27
28
|
// handler index of a dynamic path, or -1 for a static path terminal
|
|
28
29
|
#index;
|
|
29
30
|
#varIndex;
|
|
30
|
-
#children =
|
|
31
|
+
#children = createNullObject();
|
|
31
32
|
insert(tokens, index, paramMap, context, isStatic) {
|
|
32
33
|
let node = this;
|
|
33
34
|
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
@@ -105,6 +106,9 @@ var Node = class _Node {
|
|
|
105
106
|
}
|
|
106
107
|
};
|
|
107
108
|
export {
|
|
109
|
+
LABEL_REG_EXP_STR,
|
|
108
110
|
Node,
|
|
109
|
-
|
|
111
|
+
ONLY_WILDCARD_REG_EXP_STR,
|
|
112
|
+
PATH_ERROR,
|
|
113
|
+
TAIL_WILDCARD_REG_EXP_STR
|
|
110
114
|
};
|
|
@@ -5,25 +5,25 @@ import {
|
|
|
5
5
|
UnsupportedPathError
|
|
6
6
|
} from "../../router.js";
|
|
7
7
|
import { checkOptionalParameter } from "../../utils/url.js";
|
|
8
|
+
import { createNullObject } from "../utils.js";
|
|
8
9
|
import { match, emptyParam } from "./matcher.js";
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
LABEL_REG_EXP_STR,
|
|
12
|
+
ONLY_WILDCARD_REG_EXP_STR,
|
|
13
|
+
PATH_ERROR,
|
|
14
|
+
TAIL_WILDCARD_REG_EXP_STR
|
|
15
|
+
} from "./node.js";
|
|
10
16
|
import { Trie } from "./trie.js";
|
|
11
|
-
var wildcardRegExpCache =
|
|
17
|
+
var wildcardRegExpCache = createNullObject();
|
|
12
18
|
function buildWildcardRegExp(path) {
|
|
13
19
|
return wildcardRegExpCache[path] ??= new RegExp(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(
|
|
20
|
+
`^${path.replace(
|
|
21
|
+
/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,
|
|
22
|
+
(match2, metaChar) => metaChar ? `\\${metaChar}` : match2 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match2 === "*" ? ONLY_WILDCARD_REG_EXP_STR : `/:${LABEL_REG_EXP_STR}`
|
|
17
23
|
)}$`
|
|
18
24
|
);
|
|
19
25
|
}
|
|
20
|
-
function clearWildcardRegExpCache() {
|
|
21
|
-
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
22
|
-
}
|
|
23
26
|
function findMiddleware(middleware, path) {
|
|
24
|
-
if (!middleware) {
|
|
25
|
-
return void 0;
|
|
26
|
-
}
|
|
27
27
|
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
28
28
|
if (buildWildcardRegExp(k).test(path)) {
|
|
29
29
|
return [...middleware[k]];
|
|
@@ -37,8 +37,8 @@ var RegExpRouter = class {
|
|
|
37
37
|
#routes;
|
|
38
38
|
#tries;
|
|
39
39
|
constructor() {
|
|
40
|
-
this.#middleware = { [METHOD_NAME_ALL]:
|
|
41
|
-
this.#routes = { [METHOD_NAME_ALL]:
|
|
40
|
+
this.#middleware = { [METHOD_NAME_ALL]: createNullObject() };
|
|
41
|
+
this.#routes = { [METHOD_NAME_ALL]: createNullObject() };
|
|
42
42
|
this.#tries = { [METHOD_NAME_ALL]: new Trie() };
|
|
43
43
|
}
|
|
44
44
|
#insertPath(method, path) {
|
|
@@ -51,117 +51,86 @@ var RegExpRouter = class {
|
|
|
51
51
|
add(method, path, handler) {
|
|
52
52
|
const middleware = this.#middleware;
|
|
53
53
|
const routes = this.#routes;
|
|
54
|
-
if (!middleware
|
|
54
|
+
if (!middleware) {
|
|
55
55
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
56
56
|
}
|
|
57
57
|
if (!middleware[method]) {
|
|
58
58
|
this.#tries[method] = new Trie();
|
|
59
|
-
[middleware, routes]
|
|
60
|
-
handlerMap[method] =
|
|
61
|
-
|
|
59
|
+
for (const handlerMap of [middleware, routes]) {
|
|
60
|
+
handlerMap[method] = createNullObject();
|
|
61
|
+
for (const p in handlerMap[METHOD_NAME_ALL]) {
|
|
62
62
|
handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
|
|
63
63
|
this.#insertPath(method, p);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
66
|
}
|
|
67
67
|
if (path === "/*") {
|
|
68
68
|
path = "*";
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const methods = method === METHOD_NAME_ALL ? Object.keys(middleware) : [method];
|
|
71
71
|
if (/\*$/.test(path)) {
|
|
72
72
|
const re = buildWildcardRegExp(path);
|
|
73
|
-
|
|
74
|
-
if (
|
|
73
|
+
for (const m of methods) {
|
|
74
|
+
if (!middleware[m][path]) {
|
|
75
75
|
this.#insertPath(m, path);
|
|
76
76
|
middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
77
77
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
re.test(p) &&
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
Object.keys(routes).forEach((m) => {
|
|
87
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
88
|
-
Object.keys(routes[m]).forEach(
|
|
89
|
-
(p) => re.test(p) && routes[m][p].push([handler, paramCount])
|
|
90
|
-
);
|
|
78
|
+
}
|
|
79
|
+
for (const handlerMap of [middleware, routes]) {
|
|
80
|
+
for (const m of methods) {
|
|
81
|
+
for (const p in handlerMap[m]) {
|
|
82
|
+
re.test(p) && handlerMap[m][p].push([handler, path]);
|
|
83
|
+
}
|
|
91
84
|
}
|
|
92
|
-
}
|
|
85
|
+
}
|
|
93
86
|
return;
|
|
94
87
|
}
|
|
95
88
|
const paths = checkOptionalParameter(path) || [path];
|
|
96
|
-
for (
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.#insertPath(m, path2);
|
|
102
|
-
routes[m][path2] = [
|
|
103
|
-
...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
routes[m][path2].push([handler, paramCount - len + i + 1]);
|
|
89
|
+
for (const path2 of paths) {
|
|
90
|
+
for (const m of methods) {
|
|
91
|
+
if (!routes[m][path2]) {
|
|
92
|
+
this.#insertPath(m, path2);
|
|
93
|
+
routes[m][path2] = findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || [];
|
|
107
94
|
}
|
|
108
|
-
|
|
95
|
+
routes[m][path2].push([handler, path2]);
|
|
96
|
+
}
|
|
109
97
|
}
|
|
110
98
|
}
|
|
111
99
|
match = match;
|
|
112
100
|
buildAllMatchers() {
|
|
113
|
-
const matchers =
|
|
114
|
-
Object.keys(this.#routes)
|
|
115
|
-
matchers[method]
|
|
116
|
-
}
|
|
101
|
+
const matchers = createNullObject();
|
|
102
|
+
for (const method of Object.keys(this.#routes)) {
|
|
103
|
+
matchers[method] = this.#buildMatcher(method);
|
|
104
|
+
}
|
|
117
105
|
this.#middleware = this.#routes = this.#tries = void 0;
|
|
118
|
-
|
|
106
|
+
wildcardRegExpCache = createNullObject();
|
|
119
107
|
return matchers;
|
|
120
108
|
}
|
|
121
109
|
#buildMatcher(method) {
|
|
122
110
|
const middleware = this.#middleware[method];
|
|
123
111
|
const routes = this.#routes[method];
|
|
124
112
|
const trie = this.#tries[method];
|
|
125
|
-
const staticMap =
|
|
113
|
+
const staticMap = createNullObject();
|
|
126
114
|
const handlerData = [];
|
|
127
|
-
[
|
|
115
|
+
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
116
|
+
for (const r of [middleware, routes]) {
|
|
128
117
|
for (const path in r) {
|
|
129
118
|
const handlers = r[path];
|
|
130
119
|
const pathData = trie.paths[path];
|
|
131
120
|
if (!pathData) {
|
|
132
|
-
staticMap[path] = [handlers.map(([h]) => [h,
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
const paramAssoc = pathData[1];
|
|
136
|
-
handlerData[pathData[0]] = handlers.map(([h, paramCount]) => {
|
|
137
|
-
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
138
|
-
paramCount -= 1;
|
|
139
|
-
for (; paramCount >= 0; paramCount--) {
|
|
140
|
-
const [key, value] = paramAssoc[paramCount];
|
|
141
|
-
paramIndexMap[key] = value;
|
|
142
|
-
}
|
|
143
|
-
return [h, paramIndexMap];
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
148
|
-
for (let i = 0, len = handlerData.length; i < len; i++) {
|
|
149
|
-
for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
|
|
150
|
-
const map = handlerData[i][j]?.[1];
|
|
151
|
-
if (!map) {
|
|
121
|
+
staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
|
|
152
122
|
continue;
|
|
153
123
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
124
|
+
handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [
|
|
125
|
+
h,
|
|
126
|
+
trie.paths[handlerPath][1].reduceRight((map, [key], i) => {
|
|
127
|
+
map[key] = paramReplacementMap[pathData[1][i][1]];
|
|
128
|
+
return map;
|
|
129
|
+
}, createNullObject())
|
|
130
|
+
]);
|
|
158
131
|
}
|
|
159
132
|
}
|
|
160
|
-
|
|
161
|
-
for (const i in indexReplacementMap) {
|
|
162
|
-
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
163
|
-
}
|
|
164
|
-
return [regexp, handlerMap, staticMap];
|
|
133
|
+
return [regexp, indexReplacementMap.map((i) => handlerData[i]), staticMap];
|
|
165
134
|
}
|
|
166
135
|
};
|
|
167
136
|
export {
|